Class Templates

Program:


    #include<iostream.h>
    #include<conio.h>
template<class T> class sample { private: T value; public: sample() {} void display() { cout<<'\n\nConstructor is called"<<endl; cout<<"\n\nContents of the values="<<value<<endl; } }; void main() { clrscr(); sample<int>obj1; obj1.display(); sample<float>obj2; obj2.display(); getch(); }
Powered by nasrullah.in - TechnoNasr 2003-2020.
Designed & Developed by Mohamed Nasrullah.M