A CONSTRUCTOR IS A MEMBER FUNCTION THEN WHY DO U THINK OBJECTS CANNOT BE USED AS PARAMETERS.WE USE CONSTRUCTOR_NAME(OBJECT &); IN COPY CONSTUCTOR BUT NOT
CONSTRUCTOR_NAME(OBJECT);
WHY CONSTRUCTOR ALTHOUH A MEMBER FUNCTION CANNOT TAKE OBJECT AS PARAMETER, IT TAKES OBJECT PASSED BY REFERENCE AS PARAMETER AS IN COPY CONSTRUCTOR.
Because if it is not by reference, it has to be either
1. a call by value
or
2. a call by address (through pointers).
Each of these methods has a problem.
In the first case (where the object is passed BY-VALUE), the formal parameter needs to be created with the exact state as that of the actual parameter object which leads to the invocation of the copy constructor recursively infinitely.
In the second case (where we pass a pointer), there is a chance that a NULL pointer or an uninitialized pointer be passed as a parameter in which case the application will crash.
To avoid these two problems, reference variables are the best solution. First problem is obviously resolved by using references. And coming to the second problem... when we have a reference variable, if we pass an initialized pointer, the compiler itself will show an error; so there would not be a chance of runtime error.