Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Point {
  7. private:
  8.     double x, y;
  9.  
  10. public:
  11.     Point(double xx, double yy) : x(xx), y(yy) {}
  12.     const double getX() {
  13.         return x;
  14.     }
  15.     const double getY() {
  16.         return y;
  17.     }
  18.    
  19.     friend ostream &operator<<(ostream &output, Point & p) {
  20.         output << '(' << p.getX() << ',' << p.getY() << ')';
  21.         return output;
  22.     }
  23.    
  24. };
  25.  
  26. int main() {
  27.     Point a(1, 2);
  28.     Point * b = new Point(7, 9);
  29.     cout << a << ' ' << *b << endl;
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement