Default Data Types as Parameters to Generic Classes






This video tutorial explains how to specify default datatypes during the generic class definition.
You are gonna learn what happens when we specify the default datatypes with generic class definition, how we can create objects from the generic class when it has default datatypes specified, in which order we have to pass default parameters to generic class definition in detail with example.

source code for this tutorial

#include 

using namespace std;

template class MyClass{

Type1 p1;
Type2 p2;

public:
    MyClass(Type1 x, Type2 y){
    p1 = x;
    p2 = y;
    }
    void whatYouGot(){
    cout << "i got "< ob1("anil",24);
MyClass  ob2(22.36,55);
MyClass  ob3(21,"anjali");

ob1.whatYouGot();
ob2.whatYouGot();
ob3.whatYouGot();

    return 0;
}

 
Back To Top