Regarding Template class

Hi all,

I have a doubt in using normal class and templated class. Why do we use formal template syntax to each individual function.

How it differs from using the normal class.

Thank you,
Shruthi LS
A template class is not actually a class, until it is substantiated for a particular type. That is, it is merely a "template" for the compiler to generate multiple classes at instantiation-time. This means that when you substantiate a template class for "double" and substantiate it for "int", both instantiations will be of a different type (since they will be instances of unrelated classes).

That is different from a regular class, where all instances are of the same type.
Last edited on
@Toasty, "instantiate" (create an instance of), not "substantiate" (provide evidence in support of). :-)
Last edited on
Topic archived. No new replies allowed.