Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Point
- {
- private:
- //protected:
- int coords[2];
- int secretMethod() {};
- public:
- void show() {/* point specific code*/ };
- void hide() {/* point specific code*/ };
- void move(int dx, int dy) { hide(); coords[1] += dx; coords[0] += dy; show(); }
- bool setX(int aX)
- {
- if (aX < -1000 or aX > 1000 )
- {
- return false;
- }
- coords[1] = aX;
- return true;
- };
- bool setY(int aY)
- {
- if (aY < -1500 or aY > 1500)
- {
- return false;
- }
- coords[0] = aY;
- return true;
- };
- int getX() { return coords[1]; };
- int getY() { return coords[0]; };
- };
- class Circle : public Point
- {
- int r;
- public:
- // void printXY() { std::cout << x << y; }
- // void show() {/* circle specific code*/};
- // void hide() {/* circle specific code*/ };
- };
- int main()
- {
- Point myPoint; // myPoint.x myPoint.y
- //myPoint.x = 10;
- //myPoint.y = 20;
- //myPoint.secretMethod();
- myPoint.setX(0);
- myPoint.setY(0);
- if (myPoint.setX(900))
- {
- std::cout << "x changed successfuly!\nx = " << myPoint.getX() << '\n';
- }
- else
- {
- std::cout << "x UNchanged! Check value!\nx = " << myPoint.getX() << '\n';
- }
- myPoint.hide();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement