Polymorphism Q6.

Polymorphism Q6.

  1. Define “virtual function.”

In object-oriented programming, in languages such as C++, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated. This concept is an important part of the (runtime) polymorphism portion of object-oriented programming (OOP).

In object-oriented programming, in languages such as C++, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated. This concept is an important part of the (runtime) polymorphism portion of object-oriented programming (OOP).

LINK1 

  1. Define “pure virtual function.”

Answer to link 

  1. Describe how to implement virtual functions using function pointers. (This is what C++ does internally.)
  2. Define “abstract class.”
  3. Why can’t you use an abstract class to define a variable?
  4. Why should an abstract class have a virtual destructor? Explain in detail.
  5. What is the difference between Association, Aggregation and Composition?
  6. How are these class relationships implemented in C++?
  7. What is the meaning of const in a function declaration like void test() const; ?
  8. Assume you need an array to store an unknown number of animals of various kinds. How would you declare this array?