#include#include #include using namespace std; int main() { Point p(10, 20); cout << "Point p's x-coordinate: " << p.getX() << endl; cout << "Point p's y-coordinate: " << p.getY() << endl; return 0; }
Point p's x-coordinate: 10 Point p's y-coordinate: 20
#includeusing namespace std; class Point { private: int x, y; public: Point(int xx = 0, int yy = 0) : x(xx), y(yy) {} int getX() const { return x; } int getY() const { return y; } }; int main() { Point p(5, 10); cout << "Point p's y-coordinate: " << p.getY() << endl; return 0; }
Point p's y-coordinate: 10Package/Library: None (custom implementation)