Mega Code Archive

 
Categories / C++ / Generic
 

Generic Class just for displaying the parameters

#include <iostream> #include <fstream> using namespace std; template <class CoordType> class MyClass {   CoordType x, y; public:   MyClass(CoordType i, CoordType j) {       x = i;       y = j;    }   void show() {       cout << x << ", " << y << endl;    } }; int main() {   MyClass<int> object1(1, 2), object2(3, 4);     object1.show();   object2.show();   MyClass<double> object3(0.0, 0.23), object4(10.19, 3.098);   object3.show();   object4.show();   return 0; }