Introduction to Templates In C++
Templates:
Templates in C++ allow you to create objects of any type. In other programming languages like C# this is also referred to as generics. In the datastructures and algorithms class we are expected to understand what templates are and how to use them.
Note: Templates are compiled when they are required so that means you have to put the class definition and implementation in the same file.
Templates in C++ allow you to create objects of any type. In other programming languages like C# this is also referred to as generics. In the datastructures and algorithms class we are expected to understand what templates are and how to use them.
template <class G> G sampleFunction(G a){ return a; }
Note: Templates are compiled when they are required so that means you have to put the class definition and implementation in the same file.
Comments
Post a Comment