4 ms·
But C++ was never easy to understand. For example, can you tell me off the top of your head, what are the conditions to get the compiler to generate a copy cons
by KKKKkkkk1 10y ago
But C++ was never easy to understand. For example, can you tell me off the top of your head, what are the conditions to get the compiler to generate a copy constructor and an assignment operator for a class? I have trouble answering that question even with the help of Google, and you're talking pre-Google times.
- sqeaky 10y agoThe rules really aren't that hard for practical use. Of course pedantic rules in the standard are much more complex and corner cases can bite us. If you define no constructors then the compiler will generate a default constructor with no args, a copy constructor, a move constructor and an assignment operator. If any class data members don't have one of those then the class you are writing won't have one either. The simplest practical rule is define none of them or define all of them. It is not often, perhaps one in ten classes, that you should do something else. If wind up using C++ for more than a small project, than you ought read up and not use simple heuristics like this.