Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- class Point1
- {
- protected:
- int x;
- public:
- Point1(int sx)
- {
- x = sx;
- }
- void Set(int sx)
- {
- x = sx;
- }
- int Get_x()
- {
- return x;
- }
- };
- class Point2 : public Point1
- {
- protected:
- int y;
- public:
- Point2(int sx, int sy) : Point1(sx)
- {
- y = sy;
- }
- void Set(int sx)
- {
- Point1::Set(sx);
- }
- void Set(int sx, int sy)
- {
- Set(sx);
- y = sy;
- }
- int Get_y()
- {
- return y;
- }
- };
- class Point3 : public Point2
- {
- protected:
- int z;
- public:
- Point3(int sx, int sy, int sz) : Point2(sx, sy)
- {
- z = sz;
- }
- void Set(int sx)
- {
- Point1::Set(sx);
- }
- void Set(int sx, int sy)
- {
- Point2::Set(sx, sy);
- }
- void Set(int sx, int sy, int sz)
- {
- Set(sx, sy);
- z = sz;
- }
- int Get_z()
- {
- return z;
- }
- };
- int main()
- {
- Point3 p(1, 1, 1);
- cout << p.Get_x() << " " << p.Get_y() << " " << p.Get_z() << "\n";
- p.Set(2);
- cout << p.Get_x() << " " << p.Get_y() << " " << p.Get_z() << "\n";
- p.Set(2, 2);
- cout << p.Get_x() << " " << p.Get_y() << " " << p.Get_z() << "\n";
- p.Set(2, 2, 2);
- cout << p.Get_x() << " " << p.Get_y() << " " << p.Get_z() << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement