Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C++ Language/Objects/Inheritance/PolymorphismSyntax

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Frequently, an object is allocated by instantiating the derived class, but "pointed-at" by a pointer variable whose type is "pointer-to-base-class": CRBase* poBase = (CRBase*)(new CRDerived);. If CRBase and CRDerived have provided two different implementations of the same DoAction() member function, then poBase->DoAction() would call the base class' implementation. But if the member function had been marked by the virtual keyword, then poBase->DoAction() would instead "polymorphically" call the derived class' implementation. Additional information about polymorphism syntax