1.

What is the difference between virtual functions and pure virtual functions?

Answer»

A virtual function is a member function in the base CLASS that you redefine in a derived class. It is declared using the virtual keyword.

Example-

class base{public: virtual VOID fun(){ }};

A pure virtual function is a function that has no IMPLEMENTATION and is declared by assigning 0. It has no body.

Example-

class base{public: virtual void fun()=0;};

Here, = sign has got nothing to do with the assignment, and value 0 is not assigned to anything. It is used to SIMPLY tell the compiler that a function will be pure and it will not have anybody.



Discussion

No Comment Found