Home »

What are Templates

Question ListCategory: cWhat are Templates
shah_kajal184 author asked 9 years ago
1 Answers
denielshakespeare5 author answered 8 years ago

C++ Templates allow u to generate families of functions or classes that can operate on a
variety of different data types, freeing you from the need to create a separate function or

class for each type. Using templates, u have the convenience of writing a single generic

function or class definition, which the compiler automatically translates into a specific version

of the function or class, for each of the different data types that your program actually uses.

Many data structures and algorithms can be defined independently of the type of data they

work with. You can increase the amount of shared code by separating data-dependent

portions from data-independent portions, and templates were introduced to help you do that.

Please login or Register to Submit Answer