GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Concepts  >  OOPS

 Print  |  
Question:  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



February 02, 2006 09:57:02 #4
 Rahul Vij   Member Since: Visitor    Total Comments: N/A 

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

     

 

Back To Question