conversions/point1.h - Class Point with conversion constructor and conversion operator, from and to double. | Lecture 4 - slide 24 : 40 Program 1 |
class Point { private: double x, y; public: Point(); // (0,7) Point(double d); // constructor from double: (d, 20) Point(double d, double e); // (d, e) Point(Point& p); // (p.x+1, p.y+2) operator double() const; // conversion operator to double: x+y double getx () const; double gety () const; }; std::ostream& operator<<(std::ostream&, const Point&);