Despite creating a complex class, the problem is that you do not want to give it a copy constructor or assignment operator. Anyone shouldn't be copying any instances of this class, in any case. Designing a copy constructor that, if used, ends the programme when called is one solution: // Works, but not optimal class no_copy { // ... public: no_copy(const no_copy&) { std::cerr << "ERROR: no_copy(no_copy) called" << std::endl; abort(); } }; Even though it functions, you should locate the problem before to compilation rather than afterwards. Give a different remedy
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Despite creating a complex class, the problem is that you do not want to give it a copy constructor or assignment operator. Anyone shouldn't be copying any instances of this class, in any case.
Designing a copy constructor that, if used, ends the programme when called is one solution:
// Works, but not optimal
class no_copy {
// ...
public:
no_copy(const no_copy&) {
std::cerr <<
"ERROR: no_copy(no_copy) called" <<
std::endl;
abort();
}
};
Even though it functions, you should locate the problem before to compilation rather than afterwards.
Give a different remedy
Step by step
Solved in 3 steps