Accenture Interview Question
AnalystsCountry: India
Interview Type: In-Person
Since this answer will depend on language, here is my answer based on C++
I don't believe that there is anything like "template class" in c++. C++ only allow you to define templates and these templates are what which define the classes which people usually think that it means "class template".
Let me try to explain with example.
template <class typeName> class myExampleClass{
...
};
Now what we have here above here is a class template. Now when you declare something like
myExampleClass<int>
is class myExampleClass which is created, works on it and the behavior is defined by class template given above. "template class" doesn't make any sense as far as C++ is concerned.
class template :
- teja September 11, 2012template <typename t1, typename t2>
class hello{
---
---
};
The above structure is generic for all types passed for t1,t2.(It is called class template)
Template class: class generated by giving values to generic types
Initialise : "hello<int>"
But, the initialisation of generic types with int, refer to classes generated from template.