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

Discussion

Which of the following defines a family of functions in the same way a class templates defines as family of classes ?

  • A.Function templates
  • B.Generic functions
  • C.Virtual function
  • D.Friend function

Answer: A

A family of functions is defined by Function templates.

In C++ a function template, such as a max function written once with a type parameter T, defines a whole family of functions, one for each type it is instantiated with, just as a class template defines a family of classes.

'Generic functions' describes what templates produce but is not the C++ construct. A virtual function supports run-time polymorphism through a base class, and a friend function is a non-member function granted access to a class's private members; neither defines a family of functions.

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

Post your comment

Please log in or register to post a comment.