May 2012
Intermediate to advanced
679 pages
16h 56m
English
Logically, when a pointer is pointing to derived class object, method from the corresponding derived class should be executed. When the pointer in question is a base class pointer, this is not happening. Somehow, the language must have a provision to circumvent this difficulty. This calls for the concept of virtual functions.
If we declare such a function as virtual in the base class then the problem gets solved. It may be noted that keyword virtual can be applied only to a method from the class. (In other words global functions cannot be declared virtual.) Let us study the syntax and effect of a virtual declaration on a base class function.
Let us redefine ...
Read now
Unlock full access