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.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here