Which of the following defines a family of functions in the same way a class templates defines as family of classes ?
MH SET - 2021, SET Exam - 2021,
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.
Please log in or register to report this question.