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 |
Which one of the following describes characteristics of "protected" inheritance? a) The base class has access only to the public or protected members of the derived class. b) The derived class has non-public, inheritable, access to all but the private members of the base class. c) The derived class has access to all members of the base class. d) The private members of the base class are visible within the derived class. e) Public members of the derived class are privately accessible from the base class.
Why c++ is created?
If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?
What is the difference between structures and unions?
Which operations are permitted on pointers?
What is the fastest c++ compiler?
How can an improvement in the quality of software be done by try/catch/throw?
What is a reference in C++?
How do I get good at c++ programming?
What is a literal in c++?
Where Malloc(), Calloc(), and realloc() does get memory?
Write a program to concatenate two strings.