Pure virtual functions

Hi all,


To make a pure virtual function we assign a zero to the member function of the base class. Why we use zero. What does this zero means. Can anyone of you please help me with this. What is the significance of using zeros

Thanks in advance

A virtual function is essentially a function pointer, so if there is no function the value is NULL, or 0.

It is a little more complex than that underneath, but that's the gist.
Hi where can i find more details on the working of pure virtual function and the reason for using zero in the base class to make it pure virtual function

Please help
A pure virtual function does not work at all - it is by definition defined as a a header only, with zero assigned to indicate this to the compiler (and developer).

The effect is that you are unable to create an instance of a class which contains a pure virtual function, and such a class is refered to as abstract.

The use of such a class is as a base class which defines the common functionality which descendant classes must implement if they are to be instanciated.

See http://www.cplusplus.com/doc/tutorial/polymorphism.html for more info.
Topic archived. No new replies allowed.