google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Templates in C++

Saturday, May 7, 2016

Templates in C++

C++ supports a mechanism known as template to implement the concept of generic programming .

Templates allows us to generate a family of classes or a family of functions to handle different types.

Template classes and functions eliminate code duplication for different types and thus make the program development easier and more manageable.

We can use multiple parameters in both the class templates and function templates.

A specific class created from a class template is called a template class and the process of creating a template class is known as instantiation. Similarly, a specific function created from a function template is called a template function.

Like other functions, template functions can be overloaded.

Member functions of a class template must be defined as function templates using the parameters of the class template.

We may also use non - type parameters such basic or derived data types as arguments templates.


No comments:

Post a Comment

रामायण

रामायण दशरथ की तीन पत्नियाँ – कौशल्या, सुमित्रा , कैकेयी दशरथ के चार पुत्र – राम,लक्ष्मण,भरत,शत्रुघ्न दशरथ: राम के पिता और कौशल के राजा कौशल...