Write the program of object oriented programming c++. Declared Rectangle(Data Members: Length and width) as a friend class of Square(Data Member: int side). Thus now, all the functions of Rectangle...


Write the program of object oriented programming c++.


Declared Rectangle(Data Members: Length and width) as a friend class of Square(Data Member: int side). Thus now, all the functions of Rectangle can directly access any private member of Square.
In the main function, the first statement created an object 'square' of the class Square, thus calling its constructor and assigning 5 to its data member side.
The second statement in the main function created an object 'rectangle' of the class Rectangle.
In the third statement, 'rectangle' called the function shape() with the object of the class Square passed as its argument. In the 'shape()' function, the value of 'side' (private data member of Square) was assigned to length and breadth. The fourth statement called the function 'getArea' of the class Rectangle.



Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here