Machine-translated by Google. Questions are authored in English.
Top

Discussion

The following feature of C++ is an example of run time polymorphism

  • A.OPERATOR OVERLOADING
  • B.POINTERS
  • C.TEMPLATES
  • D.VIRTUAL FUNCTION

Answer: D

Run time polymorphism comes from a VIRTUAL FUNCTION.

When a base class declares a function virtual and a derived class overrides it, a call through a base-class pointer or reference is bound at run time, through the virtual table, to the version for the object's actual type. This dynamic binding is run time polymorphism.

Operator overloading and templates are resolved by the compiler, so they are compile time polymorphism. Pointers are a language feature that virtual calls use, not a form of polymorphism themselves.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.