hackerrank class rectangle code example
Example: Rectangle area hackerrank solution in c++
#include <iostream>
using namespace std;
class Rectangle{
protected:
int width;
int height;
public:
virtual void display() const{
cout<< width <<' ' << height << endl;
}
};
class RectangleArea : public Rectangle {
public:
void display() const override {
cout << (width * height) << endl;
}
void read_input(){
cin >> width >> height;
}
};
int main()
{
RectangleArea r_area;
r_area.read_input();
r_area.Rectangle::display();
r_area.display();
return 0;
}