CoolInterview.com - World's Largest Collection of Interview Questions
 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


  • INTERVIEW QUESTIONS LANGUAGES C++ DETAILS
    Question :
    What is virtual constructors/destructors?



    Category C++ Interview Questions
    Rating (3.7) By 3 users
    Added on 7/19/2006
    Views 3927
    Rate it!
    Answers:

    Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object.
    There is a simple solution to this problem ? declare a virtual base-class destructor. This makes all derived-class destructors virtual even though they don?t have the same name as the base-class destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived-class object, the destructor for the appropriate class is called.

    Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error.

    Does c++ support multilevel and multiple inheritance?
    Yes.

    What are the advantages of inheritance?
    ? It permits code reusability.
    ? Reusability saves time in program development.
    ? It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a system becomes functional.


    What is the difference between declaration and definition?
    The declaration tells the compiler that at some later point we plan to present the definition of this declaration.
    E.g.: void stars () //function declaration

    The definition contains the actual implementation.
    E.g.: void stars () // declarator
    {
    for(int j=10; j>=0; j--) //function body
    cout<<?*?;
    cout<<endl;
    }





    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

       
    Related Questions
    View Answer
    What do you mean by pure virtual functions?


    View Answer
    What is namespace?


    View Answer
    What is RTTI?


    View Answer
    What is a template?


    View Answer
    What do you mean by inline function?


    View Answer
    What is virtual class and friend class?
    View Answer
    What is function overloading and operator overloading?


    View Answer
    Difference between realloc() and free()?


    View Answer
    What do you mean by binding of data and functions?


    View Answer
    What is friend function?


    View Answer

    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

    User Options
    Sponsored Links


    Copyright ©2003-2009 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions
    Page URL: http://www.coolinterview.com/interview/6160/default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | Joke of the Day

    0.42