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 do you mean by pure virtual functions?



    Category C++ Interview Questions
    Rating (4.0) By 1 users
    Added on 7/19/2006
    Views 3747
    Rate it!
    Answers:

    A pure virtual member function is a member function that the base class forces derived classes to provide. Normally these member functions have no implementation. Pure virtual functions are equated to zero.
    class Shape {
    public:
    virtual void draw() = 0;
    };





    pure virtual means declaration of function with followed by virtual in base class. but the definition of the function is inside inherited class means derived class. whenver we want to extending the functionalities in derived class we inherited the same function name in derived class.



     Posted by: nagaraju    

    Contact nagaraju  Contact nagaraju

    Pure virtual functions are used only when the programmer knows that the base class is not going to be used anyway.

    When a function is declared as pure virtual, the compiler registers an entry for the function in to the VTABLE, but the address for the function is not mentioned in the VTABLE. So even if one function in a class is pure virtual, the VTABLE becomes incomplete. Since the VTABLE is incomplete, when we try to instantiate the class, the compiler returns error.

    This helps for object Slicing as the programmer is never able to create object of the base class... So definitely it is not possible to pass the object of the base class into some other function (By Pass-by-Value).



     Posted by: Manas Ranjan Padhy    

    Contact Manas Ranjan Padhy  Contact Manas Ranjan Padhy

    pure virtual fuinction means the base class does not contain any defenitions
    void dis=0;



     Posted by: muthuraj    

    Contact muthuraj  Contact muthuraj


    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 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
    What is public, protected & private?


    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/6159/default.asp?cachecommand=bypass


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

    0.53