We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Here's my code, pretty simple, easy to understand. The comments will help you :)
classRectangle{public:intwidth;// Represents the width of the rectangleintheight;// Represents the height of the rectangle// Virtual function for displaying rectangle propertiesvirtualvoiddisplay(){cout<<width<<" "<<height<<endl;}};classRectangleArea:publicRectangle{public:voidread_input(){cin>>width;// Reads the width from the user inputcin>>height;// Reads the height from the user input}// Overrides the display() method from the base classvoiddisplay()override{cout<<width*height<<endl;// Displays the area of the rectangle }};
Rectangle Area
You are viewing a single comment's thread. Return to all comments →
Here's my code, pretty simple, easy to understand. The comments will help you :)