C++ Programming Question:

Download Job Interview Questions and Answers PDF

What is a template in C++?

C++ Programming Interview Question
C++ Programming Interview Question

Answer:

Templates allow to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until certain point they fulfill the functionality of a macro. Its prototype is any of the two following ones:


template <class indetifier> function_declaration; template <typename indetifier> function_declaration;

The only difference between both prototypes is the use of keyword class or typename, its use is indistinct since both expressions have exactly the same meaning and behave exactly the same way.

Download C++ Programming Interview Questions And Answers PDF

Previous QuestionNext Question
Does c++ support multilevel and multiple inheritance?Define a constructor - What it is and how it might be called (2 methods).