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

Showing Answers 1 - 14 of 14 Answers

Debasis

  • Oct 20th, 2005
 

NC

  Was this answer useful?  Yes

chandan

  • Oct 21st, 2005
 

operator overloading

  Was this answer useful?  Yes

rajkishore

  • Oct 21st, 2005
 

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.

  Was this answer useful?  Yes

Rahul Vij

  • Feb 1st, 2006
 

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

  Was this answer useful?  Yes

vijay saxena

  • Oct 23rd, 2006
 

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.

vijay

  Was this answer useful?  Yes

Sunny

  • May 7th, 2007
 

Definitly the constructor should be invoked, but can "=" be overloaded ? i doubt it cannot.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions