Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. struct Point
  5. {
  6. int x;
  7. int y;
  8. void print()
  9. { // Point* const this
  10. cout<<"("<<(*this).x<<";"<<y<<")";
  11. }
  12. };
  13.  
  14. struct Circle
  15. {
  16. double r;
  17. Point p;
  18.  
  19. void print() {
  20. cout << r << " ";
  21. p.print();
  22. cout << endl;
  23. }
  24. };
  25.  
  26. struct Rectangle
  27. {
  28. double width;
  29. double height;
  30. Point p; //top left
  31. void print()
  32. {
  33. cout<<width<<" "
  34. <<height<<" ";
  35. p.print();
  36. cout<<endl;
  37. }
  38. };
  39.  
  40. struct Window
  41. {
  42. Circle circles[2];
  43. Rectangle rectangles[2];
  44.  
  45. void print(){
  46. for(Circle & c: circles) {
  47. c.print();
  48. }
  49. for(Rectangle & r: rectangles) {
  50. r.print();
  51. }
  52. }
  53. };
  54.  
  55. int main()
  56. {
  57. Point p{5,10};
  58. Rectangle r{3,4,p};
  59. Circle c{6,p}; //{6,{5,10}}
  60.  
  61. p.print();
  62. c.print();
  63.  
  64. Window w1{{c,c},{r,r}};
  65. Window w2{{c,c},{r,r}};
  66. w1.print();
  67. cout << endl;
  68. w2.print();
  69. return 0;
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement