what is the use of templates?
Answers were Sorted based on User's Feedback
Answer / aboelella
Template is used to optimize code
instead of implementing the same code for multiple data
types, template works as a way to declare classes and
functions and then to be implemented with different data types
It is dependent on the data structure used to substitute the
template
| Is This Answer Correct ? | 18 Yes | 0 No |
Answer / achal
In C++ there are 2 kinds of templates. i) function
templates ii) Class templates.
Among these class templates are more common.
e.g.
template <class T > class Sample
{
public:
T m1;
void fun(T);
};
Now here we have created a class which has a data member of
type T. Now this T can be int, unsigned int, char etc.
Thus templates are said to be used for generic programming.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer /
templates are used for GENERIC.....Programing...
by using templates.....you can write program for generic
linked list .
tempaltes make code reusable....
| Is This Answer Correct ? | 1 Yes | 2 No |
What are the different data types present in C++?
What do you mean by abstraction. Explain your answer?
Write a program to encrypt the data in a way that inputs a four digit number and replace each digit by (the sum of that digit plus 7) modulus 10. Then sweep the first digit with the third, second digit with the fourth and print the encrypted number.
Evaulate: 22%5 a) 2 b) 4 c) 0
What relational operators if statements in c++?
How do you establish a has-a relationship?
Where must the declaration of a friend function appear?
Can notepad ++ run c++?
What is an operator in c++?
program in c++ to input digits and print in words
When should we use container classes instead of arrays?
What are the three types of access specifiers in C++?