It is not Const. pointer in copy constructor but const Reference of object of same class type which we do pass in copy constructor.... and everyone has given pretty good answers for two questions
1) what is importance of const. reference object of same class type in copy const...
2) Why do we use reference of class instead of simple pass by value.
Again one query why dont we use pass by pointer in copy constructor so see following scenario
class ABC
{
public:
ABC(){} /*Simple Constructor*/
ABC(ABC * b) { }/*Copy Constructor*/
};
int main(int argc, char* argv[]){
ABC * d1 = NULL;
ABC d2 = d1; /*Calling Copy constructor*/
return 0;
}
See above example , if we take pointer type object in copy constructor
two flaws are here 1) We can assign NULL value to simple object of that class
2) see this line ABC d2 = d1;
here d2 is ABC type while d1 is ABC* type means as per rule we are violating basic rules by allowing to assign simple type with pointer type.
If there is any pointer type member variable in side ABC class means DEEP Copy scenario like int * m_iVal; then it will crash out during calling copy constructor by passing NULL object... so stop such mistake at design time we do use const reference object of same class type in copy constructor as a parameter.Hoping this will clear you.