What are templates? where we should use it?

Answer Posted / prabhatkr09

Template allow us to write one function and class that works for different datatype .

Use :

Create a type safe collection class that can operate on data of any type.

add extra type checking for function.

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the purpose of the keyword volatile.

638


Explain operator overloading.

604


Differentiate between the manipulator and setf( ) function?

596


What is std namespace in c++?

726


What is the object serialization?

629






In int main(int argc, char *argv[]) what is argv[0] a) The first argument passed into the program b) The program name c) You can't define main like that

617


How do you clear a buffer in c++?

542


When should we use multiple inheritance?

617


What is the basic of c++?

606


What is the use of setprecision in c++?

548


Define whitespace in C++.

758


total amount of milk produced each morning and then calculates and outputs the number of cartons needed for this milk , the cost of producing the milk and the profit from producing this milk.

2082


Why is it necessary to use a reference in the argument to the copy constructor?

637


What are formatting flags in ios class?

610


What is the use of register keyword with the variables?

551