What do you mean by pure virtual functions?  

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; 
}; 
 

Showing Answers 1 - 26 of 26 Answers

Solomon

  • Jul 25th, 2006
 

And what about entry for pure virtual function in base class virtual table ?? Is this entry empty or equal to NULL?

  Was this answer useful?  Yes

Prateek Joshi

  • Oct 8th, 2006
 

Hi

pure virtual function r the function in which

 expresssion =0;

 iss present.

krisgroup

  • Oct 22nd, 2007
 

hi,

adding to above comment,

it makes it as a rule to add the implementation in the derived class,
or else the derived class inturn becomes an abstract class.

chaitanya

  Was this answer useful?  Yes

internally it tells the compiler to reserve a slot for a function in the VTABLE but not to put an address in the particular slot.
Thus the VTABLE is incomplete.

  Was this answer useful?  Yes

Pure virtual function is a virtual function which has no defination in base class but must be redefined in derieved class or else compile time error will be generated by the compiler.

any class which is having atleast on pure virtual function is termed as an abstract base class (ABC), which cannot be instanciated, but we can have a reference or pointer to that class.

for eg :

class myclass {
public:
            virtual void display() = 0; //pure virtual function with no defination here...
};

class der : public myclass {
public:    /*must be redefined in derieved class */
            void display() {
                                      cout << "blah blah........" << "n";
                            }
};

  Was this answer useful?  Yes

Pure virtual function is the virtual functions which member functions does not have any definitions(implementation),just it equates(=) to 0.
With Pure virtual function, the base class becomes "Abstract class". The abstract class does not instantiate/ create objects. But it's pointers can be assigned with Derived class objects.
The pure virtual member functions must be overriden in derived classes.

Hope it helps you in understanding, Thanks, Niranjan ambati

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions