Class template with multiple parameters Last Updated : 27 Jun, 2017 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisite: Templates in C++ While creating templates, it is possible to specify more than one type. We can use more than one generic data type in a class template. They are declared as a comma-separated list within the template as below: Syntax: template<class T1, class T2, ...> class classname { ... ... }; CPP // CPP program to illustrate // Class template with multiple parameters #include<iostream> using namespace std; // Class template with two parameters template<class T1, class T2> class Test { T1 a; T2 b; public: Test(T1 x, T2 y) { a = x; b = y; } void show() { cout << a << " and " << b << endl; } }; // Main Function int main() { // instantiation with float and int type Test <float, int> test1 (1.23, 123); // instantiation with float and char type Test <int, char> test2 (100, 'W'); test1.show(); test2.show(); return 0; } Output: 1.23 and 123 100 and W Explanation of the code: In the above program, the Test constructor has two arguments of generic type. The type of arguments is mentioned inside angle brackets < > while creating objects. When argument is more than one, they are separated by commas. Following statement Test test1 (1.23, 123);tells the compiler that the first argument is of type float and another one is int type. During creation of objects, constructor is called and values are received by template arguments. If you like GeeksforGeeks(We know you do!) and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to [email protected]. Comment More infoAdvertise with us Next Article Constructors in C++ S Sakshi_Tiwari Improve Article Tags : Misc C++ STL Practice Tags : CPPMiscSTL Similar Reads Java.lang.Class class in Java | Set 1 Java provides a class with name Class in java.lang package. Instances of the class Class represent classes and interfaces in a running Java application. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects. It 15+ min read Types of Operator Overloading in C++ C++ provides a special function to change the current functionality of some operators within its class which is often called as operator overloading. Operator Overloading is the method by which we can change some specific operators' functions to do different tasks.Syntax: Return_Type classname :: op 4 min read Generic Class in Java Java Generics was introduced to deal with type-safe objects. It makes the code stable.Java Generics methods and classes, enables programmer with a single method declaration, a set of related methods, a set of related types. Generics also provide compile-time type safety which allows programmers to c 4 min read C# Params Params is an important keyword in C#. It is used as a parameter which can take the variable number of arguments of specific data type. It is a useful feature when the number of arguments is unknown, providing flexibility in method calls. Some key points involved with params in C# are mentioned below 3 min read Constructors in C++ In C++, constructors are special methods that are automatically called whenever an object of a class is created. The constructor in C++ has the same name as the class or structure.Example:C++#include <iostream> using namespace std; class A { public: // Constructor of the class without // any p 6 min read How to Create a Template Class in C++? In C++, template classes are used to create generic classes that can work for different data types. In this article, we will learn how to create a template class in C++. Create a Template Class in C++ To create a template class in C++, we can follow the below syntax: Syntax of Template Classtemplate 2 min read Like