Default methods written by compiler:
If nothing is declared inside a class as shown below
The compilers will declare their own versions of a copy constructor, an assignment operator, a destructor, and a pair of address-of operators as shown below.
All the above methods are public.
The following code will cause each function to be generated.
The default copy constructor (assignment operator) performs member wise copy construction (assignment) of the non-static data members of the class.
Consider the definition of the named template
Since the class has one constructor defined, the compiler does not generate the default constructors.
NamedObject<int> no1("Smallest Prime Number", 2);
NamedObject<int> no2(no1); // calls copy constructor
Post a Comment