ProgrammingVery hardProduct-company placement · C++

How many of these are resolved at COMPILE time in C++? (i) Which function body a call to a non-virtual member function through a base-class pointer executes (ii) Which of several overloaded functions a call selects (iii) Which function body a call to a virtual function through a base-class reference executes (iv) Which instantiation of a function template a call uses

  1. A. 2
  2. B. 3
  3. C. 4
  4. D. 1

Correct answer: B. 3

(i), (ii) and (iv) are static (early binding): non-virtual calls use the static type, and overloads and template arguments are chosen by the compiler. Only (iii), virtual dispatch, depends on the run-time type.

More OOP with C++ and Java questions

Exams that ask this topic