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

Templates and Generics Questions and Answers

1.

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

Exam Year(s)

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.

Loading…

Other Subjects

Tags: Templates and Generics Questions and Answers || Templates and Generics MCQ Questions and Answers || Templates and Generics GK Questions and Answers || Templates and Generics GK MCQ Questions || Templates and Generics Multiple Choice Questions and Answers || Templates and Generics GK || GK on Templates and Generics || Object Oriented Programming Questions and Answers || Object Oriented Programming MCQ Questions and Answers || Object Oriented Programming GK Questions and Answers || GK on Object Oriented Programming