CoolInterview.com - World's Largest Collection of Interview Questions
Home| Ask Questions| About Us| Feedback| Contact Us|
 Interview Questions  
 Our Services  

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies

  • COOLINTERVIEW.COM LANGUAGES C++ DETAILS



    Question :
    What is difference between copy constructor and constructor?




    Answer :
    A copy constractor can accept a reference to its own class,where the simple constractor can't? do the job.

    Copy Constructor is used to copy the values of one object to another object. Argument for copy constructor is the object of its own class. it can be defined as follows
    Student(Student S){----}
    Student is a class.
    it can be called as follows: Student s1(s2)
    where s2 values are copied to s1.

     Posted by: Anant    

    Contact Author  Contact Author
    the major difference between the copy constructor and the simple constructor is that in copy constructor we are first creating the object instance on which it is called and then we are initializing the values in its member variables.
    where as in the constructor , we only assign the values to the member variables of the object instance which is already being created.

     Posted by: kishor bagul    

    Contact Author  Contact Author
    That is like asking what is the difference between a subset and its superset.

    A copy constructor is a type of constructor which has got to adhere to a predefined function prototype i.e.
    A::A(const A& a)
    What it does with the input parameter is totally upto to the code inside the constructor but the idea behind the exercise is to initialize the class object using the passed in object of the same class. The default copy constructor does a member wise copy of the input class to the destination class.

     Posted by: Samit Sasan    

    Contact Author  Contact Author
    the main difference can be explained by taking an example if we hav a=b where a,b are objects of the same class and we declare these objects before hand then we can hav constructor only but if we want to equate these objects while declaring then will hav to use copy constructor.

     Posted by: rohit mehra    

    Contact Author  Contact Author
    Copy Constructor is special member function ,who initilize the newly created object by existing object.

    if copy constructor has not implemented ,compiler provide its own.
    shalow copy concepts..

    Copy constructor can also be invoked with assignment opR.(=)



     Posted by: Arvind Pande    

    Contact Author  Contact Author

    © CoolInterview.com
    Today's Special: Get Free Magazine from SAP now!

    A D V E R T I S E M E N T








    If you have the better answer, then send it to us. We will display your answer after the approval.
    Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       


    Rate the above answer. Help us to know about the answer.
    Category C++ Interview Questions
    Rating (4.0) By 6 users
    Added 8/18/2006
    Views 6398
    Rate it!
    Free Offers 300 Free Magazines for you. No credit card required. No Shipping Charges. Absolutely Free for 1 Year.

    Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

    Notify me when better answer is posted!
    Email:

    View ALL C++ Interview Questions


    Sponsored Links  

    Google Search

    Google

    CoolInterview.com is a part of Vyom Network.
    Copyright ©2003-2009 Vyom Technosoft Pvt. Ltd., All Rights Reserved. Privacy Policy
    Page URL: http://www.coolinterview.com/interview/10846/Default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial

    1.09