What happens, in case of copy constructor, if I use pointer in the parameter instead of reference variable? for ex.
class MyClass
{
private: int a;
char *str;
public:...
...
MyClass(MyClass *pObj)
{
....
....
}
};
Copy constructor is supposed to make a copy from an object and not from pointer.
Why pass by Reference and not by value? Because if you don’t do so, the copy constructor will go in creation of the copy of the argument and it will be an endless loop.