fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Point {
  5. public:
  6. Point();
  7. Point(double x, double y) : x(x), y(y) { }
  8.  
  9.  
  10. double getX() const { return x; }
  11. double getY() const { return y; }
  12. void setX(double);
  13. void setY(double);
  14.  
  15. friend std::ostream& operator<<(std::ostream& os, const Point& obj);
  16. private:
  17. double x;
  18. double y;
  19. };
  20.  
  21. inline std::ostream& operator<<(std::ostream& os, const Point& obj) {
  22. os << "(" << obj.getX() << "," << obj.getY() << ")";
  23. return os;
  24. }
  25.  
  26. int main() {
  27. Point * p = new Point(1, 42);
  28. cout << *p << endl;
  29. return 0;
  30. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
(1,42)