Answer Posted / 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 |
Post New Answer View All Answers
What is the use of default constructor?
why is iostream::eof inside a loop condition considered wrong?
Why do we use using namespace std in c++?
What is the best c++ ide?
Is swift better than c++?
What are arrays c++?
What is ios flag in c++?
What is the purpose of the "delete" operator?
Differentiate between a constructor and a destructor in c++.
Describe about storage allocation and scope of global, extern, static, local and register variables?
In a function declaration, what does extern mean?
What are the benefits of c++?
How do you find out if a linked-list has an end?
Why are arrays usually processed with for loop?
What is std namespace in c++?