Generic Class with more than one Generic Type

This video tutorial explains the generic classes which are gonna work  with more than one generic type.
You are gonna learn how to create a generic class which is gonna operate on more than on generic type, how to use multiple generic types with generic class in your program, how to create objects from the generic classes with multiple generic types in detail with example.

source code for this tutorial

#include <iostream>

using namespace std;

template <class Type1, class Type2>class MyClass{
Type1 p1;
Type2 p2;
int counter;

    MyClass(Type1 x, Type2 y){
    p1 = x;
    p2 = y;
    counter = 100;

    void whatYouGot(){
    cout << "i got p1 = "<<p1<<" and p2 = "<<p2<<" and counter is "<<counter<<endl;

int main()
    MyClass <int,string> ob1(24,"anil");

    MyClass <float,float> ob2(22.36,66.241);


    return 0;

Back To Top