<P> In object - oriented programming , when a derived class inherits from a base class , an object of the derived class may be referred to via a pointer or reference of the base class type instead of the derived class type . If there are base class methods overridden by the derived class , the method actually called by such a reference or pointer can be bound either ' early ' ( by the compiler ) , according to the declared type of the pointer or reference , or ' late ' ( i.e. , by the runtime system of the language ) , according to the actual type of the object referred to . </P>
<P> In object - oriented programming , when a derived class inherits from a base class , an object of the derived class may be referred to via a pointer or reference of the base class type instead of the derived class type . If there are base class methods overridden by the derived class , the method actually called by such a reference or pointer can be bound either ' early ' ( by the compiler ) , according to the declared type of the pointer or reference , or ' late ' ( i.e. , by the runtime system of the language ) , according to the actual type of the object referred to . </P>
when do we need virtual functions in c++
when do we need virtual functions in c++
when a derived class inherits from a base class , an object of the derived class may be referred to via a pointer or reference of the base class type instead of the derived class type
when a derived class inherits from a base class , an object of the derived class may be referred to via a pointer or reference of the base class type instead of the derived class type