What is a virtual function in Cpp?

Answer:
A virtual function in C++ is a function that can have multiple definitions.

For example:

If you have a class which contains a virtual function:

class Virtual
{

virtual void makesomething();

};

That function can be implemented when you inherit that class an implement the function. So:

class Inherit : public Virtual
{

//this is the same function, but can be implemented to do something different
void makesomething() { //do something else }

};
First answer by Nathaneliott. Last edit by Nathaneliott. Contributor trust: 5 [recommend contributor recommended]. Question popularity: 1 [recommend question].