Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- class Point
- {
- public:
- int x;
- int y;
- public:
- //Point() : x{42}, y{33}
- Point() : Point{42,33}
- {
- std::cout << "Default constructor for Point started!\n";
- //x = 42;
- //y = 33;
- }
- Point(int pX, int pY) : x{ pX }, y{pY}
- {
- std::cout << "Parametrized X Y constructor for Point started!\n";
- /*x = pX;
- y = pY;*/
- }
- /*Point(int pX, bool all = false) : x{ pX }, y{all ? pX : 0}*/
- Point(int pX, bool all = false) : Point{ pX, all ? pX : 0 }
- {
- std::cout << "Parametrized pX constructor for Point started!\n";
- //x = pX;
- //if (all) { y = pX; }
- //else { y = 0; }
- }
- void setX(int pX) { x = pX; }
- void setY(int pY) { y = pY; }
- int getX() { return x; }
- int getY() { return y; }
- };
- class Circle
- {
- Point centre;
- int R;
- public:
- Circle() : centre{ 10,10 }, R{42}
- {
- std::cout << "Default constructor for Circle started!\n";
- /*centre.x = 10;
- centre.y = 10;*/
- //R = 42;
- }
- void info()
- {
- std::cout << "Circle info: R = " << R << ' ' << " center x = " << centre.x << " y = " << centre.y << '\n';
- }
- };
- int main()
- {
- Circle c1;
- c1.info();
- Point p1; //p1.x p1.y
- p1.setX(1);
- Point p2{22, true}; //p2.x p2.y
- //p2.setX(2);
- Point p3{33,555};
- //p3.setX(3);
- //p1.setX(3);
- //p1.setY(5);
- std::cout << p1.getX() << ' ' << p1.getY() << '\n';
- std::cout << p2.getX() << ' ' << p2.getY() << '\n';
- std::cout << p3.getX() << ' ' << p3.getY() << '\n';
- return 0;
- }
Add Comment
Please, Sign In to add comment