Skip to content

Polymorphism, abstract classes, pointers, references

Question

Give short definitions of polymorphism, an abstract class, a pointer and a reference in C++.

Short answer

Polymorphism: one interface, many behaviours, e.g. a base reference calling the right override at run time (or templates and overloading at compile time). Abstract class: has at least one pure virtual function, so it cannot be instantiated. Pointer: a variable holding an address; it can be null, reseated and do arithmetic. Reference: an alias bound to an object at initialisation, never null or reseated.

Adapted from Joshi, Denson & Downes, Quant Job Interview Questions and Answers, Q7.33, p.233; question and answer rewritten by SelfMadeQuant.com.

See the hint and the full worked solution in the question bank (free account).

Open the worked solution

Lessons behind this question