S
subramanian100in
consider
template<typename T> Test
{
// ...
};
We can have a pointer type as argument to a template class. For
example, we can have,
int x = 100;
Test<int*> obj(&x); // assuming a suitable ctor exists
But we cannot have reference type as template argument. This is
because reference cannot be assigned (in the overloaded assignment
operator) in the ordinary sense - that is, a reference cannot be
reseated. So, we cannot instantiate a template class with reference
type as argument. Is this understanding of mine, is correct ?
Kindly clarify.
Thanks
V.Subramanian
template<typename T> Test
{
// ...
};
We can have a pointer type as argument to a template class. For
example, we can have,
int x = 100;
Test<int*> obj(&x); // assuming a suitable ctor exists
But we cannot have reference type as template argument. This is
because reference cannot be assigned (in the overloaded assignment
operator) in the ordinary sense - that is, a reference cannot be
reseated. So, we cannot instantiate a template class with reference
type as argument. Is this understanding of mine, is correct ?
Kindly clarify.
Thanks
V.Subramanian