May 2012
Intermediate to advanced
679 pages
16h 56m
English
It is possible to declare and initialize the object in a slightly different form. See the declaration given below.
Period p2 = p1;
It declares a variable object p2 of class Period and initializes it with a copy of object p1. It goes without saying that p1 is already declared as an object of type Period. This form is called copy initialization. It appears to be a copy constructor. It is not so. Difference between the two is quite subtle. Actually, it involves overloaded assignment operator. It is worth noting that if we do not overload operator =, then the compiler provides a default overloaded = operator.
Read now
Unlock full access