Base class member

I have encountered following lines in base class and I do not comprehend its meaning of "= 0" at the end of the member functions;

distance_list intersect(ray & r) = 0;
appearance get_appearance(vector & pt) = 0;

where distance_list is a list of doubles and appearance is properties.
In general, what does this "equal sign and 0 " mean for the member functions in the base class? Your help will be greatly appreciated.
These functions must also be marked as virtual, right?

The "=0" bit means the function is "pure virtual". This implies a few things:

1) The base class does not need to provide a body for the function
2) The base class cannot be instantiated
3) Any derived class which does not provide a body for the function cannot be instantiated


Pure virtual functions are basically for defining "interfaces" that child classes need to adhere to.
It's means it's a pure virtual function. The base class does not need to define this function and it makes it impossible to create instances of the base class. It's a way of forcing the derived classes to override the function. If a derived class does not override all pure virtual functions you will get an error if you try to create an instance of the derived class.
Thank you for your answer. I am wiser now.
Topic archived. No new replies allowed.