Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- struct Point
- {
- int x;
- int y;
- void print()
- { // Point* const this
- cout<<"("<<(*this).x<<";"<<y<<")";
- }
- };
- struct Circle
- {
- double r;
- Point p;
- void print() {
- cout << r << " ";
- p.print();
- cout << endl;
- }
- };
- struct Rectangle
- {
- double width;
- double height;
- Point p; //top left
- void print()
- {
- cout<<width<<" "
- <<height<<" ";
- p.print();
- cout<<endl;
- }
- };
- struct Window
- {
- Circle circles[2];
- Rectangle rectangles[2];
- void print(){
- for(Circle & c: circles) {
- c.print();
- }
- for(Rectangle & r: rectangles) {
- r.print();
- }
- }
- };
- int main()
- {
- Point p{5,10};
- Rectangle r{3,4,p};
- Circle c{6,p}; //{6,{5,10}}
- p.print();
- c.print();
- Window w1{{c,c},{r,r}};
- Window w2{{c,c},{r,r}};
- w1.print();
- cout << endl;
- w2.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement