which are performed of basic data types like int , float ,char ,long etc .but copy constructor -> this can be used to assign a object of deriver data type . Folks,Copy constructor creates / has the instance (c. Diffrence between a "assignment operator" and a "copy constructor" assignment operator -> which are performed of basic data types like int , float ,char ,long etc .but copy constructor -> this can be used to assign a object of deriver data type . Folks,Copy constructor creates / has the instance (c . 4 members have posted answers.">
GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 19 of 258    Print  
Diffrence between a "assignment operator" and a "copy constructor"

  
Total Answers and Comments: 4 Last Update: February 21, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 23, 2005 01:40:15   #1  
Girish        

RE: Diffrence between a "assignment operator" and a "copy constructor"
assignment operator -> which are performed of basic data types like int float char long etc .
but copy constructor -> this can be used to assign a object of deriver data type .




 
Is this answer useful? Yes | No
September 10, 2005 22:47:01   #2  
Srini        

RE: Diffrence between a "assignment operator" and a "copy constructor"
Folks Copy constructor creates / has the instance (constructor). But for operator the you need a instance which is created either by default constructor or normal constructor.thanksSrini
 
Is this answer useful? Yes | No
September 14, 2005 12:51:06   #3  
Rongkai Xu        

RE: Diffrence between a "assignment operator" and a "...
Assignment changed the value of the object that has already been constructed. But copy constructor construct a NEW object and gives it a value at the same time.
 
Is this answer useful? Yes | No
February 21, 2008 05:00:59   #4  
ankurgarg Member Since: February 2008   Contribution: 1    

RE: Diffrence between a "assignment operator" and a "copy constructor"
In C++ assignment and copy construction are different because the copy constructor initializes uninitialized memory whereas assignment starts with an existing initialized object. If your class contains instances of other classes as data members the copy constructor must first construct these data members before it calls operator . The result is that these members get initialized twice. It's the same thing that happens with the default constructor when you initialize members using assignment instead of initializers.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape