Abstract Class: P. Vasuki P. Vasuki
Abstract Class: P. Vasuki P. Vasuki
P. Vasuki
Polymorphism
• On overriding, compiler calls the appropriate function,
defined by the type of object, which invokes the function.
Dzire_Car
virtual int milage()=0 //Pure Vitual Function
Pertrol__Dezire Deisel_Dezire
int milage() int milage()
{ {
return 22; I return 25;
} }
Virtual Destructors
• Problem:
– If base-class pointer to a derived object is deleted, the base-class
destructor will act on the object
• Solution:
– Declare a virtual base-class destructor
– Now, the appropriate destructor will be called
Polymorphism, virtual Functions and
Dynamic Binding