Tusohian

Genetic Point Class

Aug 11th, 2017
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <class Data>
  6. class Point{
  7.     Data x, y;
  8.     public:
  9.     Point(Data a, Data b){
  10.         x = a;
  11.         y = b;
  12.     }
  13.     void Display(){
  14.         cout << "(" << x << ", " << y << ")" << endl;
  15.     }
  16. };
  17. int main(){
  18.     Point<int> ob1(5, 9);
  19.     Point<double> ob2(5.6, 9.5);
  20.     ob1.Display();
  21.     ob2.Display();
  22.     return 0;
  23. }
Add Comment
Please, Sign In to add comment