28-12-2010, 05:08 PM
PRESENTED BY,
S.JAILANI BEEVI
S.JAILANI BEEVI
virtual functions.ppt (Size: 1.66 MB / Downloads: 104)
VIRTUAL FUNCTIONS
A virtual function is a member function that is declared within a base class and redefined by a derived class.
To create a virtual function, precede the function’s declaration in the base class with the keyword virtual.
When a class containing a virtual function is inherited, the derived class redefines the virtual function to fit its own needs.
Calling a Virtual Function Through a Base Class Reference
When a virtual function is called through a base-class
reference , the version of the function executed is
determined by the object being referred to at the time
of the call.
The Virtual Attribute Is Inherited
When a derived class that has inherited a virtual function is itself used as a base class for another derived class, the virtual function can still be overridden.