SHARE
TWEET

Untitled

a guest Apr 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top