A virtual function allows derived classes to replace the implementation provided by the base class. The compiler ensures that the replacement is always called whenever the object in question is actually in a derived class, even if the object is accessed by a base pointer, not a derived pointer. This allows you to replace the algorithms in the base class in the derived class, even if users are not aware of the derived class.
A derived class can either completely replace ("override") a member function of a base class, or a derived class can partially replace ("complement") a member function of a base class. The latter is true if the member function of the derived class calls, if necessary, the member function of the base class.
More details here:
http://www.codersource.net/c/c-tutorials/c-virtual-function.aspx
However, it is very simple. Try Google next time before coming here to ask!
source share