Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Square;
  6.  
  7. class Rectangle {
  8. int width, height;
  9. public:
  10. int area ()
  11. {return (width * height);}
  12. void convert (Square a);
  13. };
  14.  
  15. class Square {
  16. friend class Rectangle;
  17. private:
  18. int side;
  19. public:
  20. Square (int a) : side(a) {}
  21. };
  22.  
  23. void Rectangle::convert (Square a) {
  24. width = a.side;
  25. height = a.side;
  26. }
  27.  
  28. int main () {
  29. Rectangle rect;
  30. Square sqr (4);
  31. rect.convert(sqr);
  32. cout << rect.area();
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement