What are templates? where we should use it?

Answers were Sorted based on User's Feedback



What are templates? where we should use it?..

Answer / 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

What are templates? where we should use it?..

Answer / satheeshkumar

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 ?    1 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is the output of the following 3D Array int arr[3][2][2]={1,2,3,4,5,6,7,8,9,10,11,12}; what is the output for arr[2][1][0]?

6 Answers   HCL, Integra, IPMC, ORG,


Write a program which uses functions like strcmp(), strcpy()? etc

0 Answers  


What is doubly linked list in c++?

0 Answers  


What is the protected keyword used for?

0 Answers  


What is a vector c++?

0 Answers  






How do you declare A pointer to a function which receives nothing and returns nothing

0 Answers  


What are the unique features of C++.

0 Answers  


What is the difference between structure and class?

0 Answers  


What is the difference between a definition and a declaration?

0 Answers  


Badboy is defined who has ALL the following properties: 1. Does not have a girlfriend and is not married. 2. He is not more than 23 years old. 3. The middle name should be "Singh" 4. The last name should have more than 4 characters. 5. The character 'a' should appear in the last name at least two times. 6. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers

1 Answers  


What are friend functions in C++?

0 Answers   BlackRock,


Can a new be used in place of old mallocq? If yes, why?

0 Answers  


Categories