how we wright the templet class and function
what r the application of templat function and templat class
Collapse
X
-
You write template classes and functions to capture what is done regardless of the type of the data.
In C if you need a function to copy an array of char, you will need another function to copy and array of int, another to copy an
array of float, etc...
In C++ you write one template function to copy an array of an array of any type.
The compiler makes a copy of the template, puts in the correct type and uses this copy in your program. Basically, the compiler
generates all of the functions you would have to write in C.
Comment