while copying the objects if you say X a = b and asssume that '=' operator is overloaded then what it will call, a copy constructor or operator overloading function
Total Answers and Comments: 8
Last Update: September 12, 2008 Asked by: Amit Joshi
RE: while copying the objects if you say X a = b and a...
while doing X a b; in this statement what it will do first create the object 'a' then it will copy the value of 'b' to ' a'. so the copy constructure will call.
RE: while copying the objects if you say X a = b and a...
X a b is internally represented as X a(b). The compiler will call a copy constructor and not the overloaded operator. as for theoperator to be called the LHS object should have been instantiated before the call. but in the above case it is getting instantiated in the same call. so copy constructor will be called doing a shallow copy. a standard one will be generated by the compiler only
RE: while copying the objects if you say X a = b and a...
constructor will first call. becs this function invoked when new object is created so it first look for constructor rather than go for operator overloading.
RE: while copying the objects if you say X a = b and asssume that '=' operator is overloaded then what it will call, a copy constructor or operator overloading function
It is not operator overloading it is just copy constructor which assign that the value of b is copied to a.
RE: while copying the objects if you say X a = b and asssume that '=' operator is overloaded then what it will call, a copy constructor or operator overloading function
Copy constructor would be called to perform the deep copy of object b into object a.