explain pure virtual function.

When I just did a Google Search, on pure virtual function right now, this was at the top:

(You can do that too ... Yes ?)

When we add a pure virtual function to our class, we are effectively saying, “it is up to the derived classes to implement this function”.

Using a pure virtual function has two main consequences:

Firstly, any class with one or more pure virtual functions becomes an abstract base class, which means that it can not be instantiated! Consider what would happen if we could create an instance of Base:

int main()
{
    Base b; // pretend this was legal
    b.GetValue(); // what would this do?
}

Secondly, any derived class must define a body for this function, or that derived class will be considered an abstract base class as wel

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.