Tuesday, 17 April 2012

Define pure virtual function. | C++

Pure virtual function is defined as a virtual function in a base class. It is implemented in a derived class. A program may not declare an instance of a class that has a pure virtual function. A program may not declare an instance of a derived class if that derived class has not provided an overriding function for each pure virtual function in the base.
A pure virtual function can be created through the following way:
class Car
{
void jar() = 0;
}
car mycar; //compilation error

No comments: