K
karthikbalaguru
Hi,
What is the difference between assignment operator and Copy
constructor.
I got the following info, But have some quries based on it.
Circle C1,C2;
C1 = C2; /* Assignment Operator */
Circle C3 = C2; /*Copy Constructor*/
In Above example, It states that for Copy Constructor, the compiler
creates a new object C3 and and copies the data from C2 member-by-
meber, into C3.
It also states that the Assignment operator does not create an object.
But How ? Actually 'Circle C1' has already been done before doing 'C1
= C2'.
So, how does it state the 'Assignment operator does not create an
object' ?
What actually is the difference between the assignment operator and
the copy constructor ?
Thx in advans,
Karthik Balaguru
What is the difference between assignment operator and Copy
constructor.
I got the following info, But have some quries based on it.
Circle C1,C2;
C1 = C2; /* Assignment Operator */
Circle C3 = C2; /*Copy Constructor*/
In Above example, It states that for Copy Constructor, the compiler
creates a new object C3 and and copies the data from C2 member-by-
meber, into C3.
It also states that the Assignment operator does not create an object.
But How ? Actually 'Circle C1' has already been done before doing 'C1
= C2'.
So, how does it state the 'Assignment operator does not create an
object' ?
What actually is the difference between the assignment operator and
the copy constructor ?
Thx in advans,
Karthik Balaguru