Answers for "Rectangle Area hackerrank in c++"

C++
0

Rectangle Area hackerrank in c++

#include <iostream>
using namespace std;
class Rectangle
{
   protected:
      int width;
      int height;
   public:
      virtual void display()
      {
          cout<<width<<" "<<height<<"n";
      }
};

class RectangleArea :public Rectangle
{
    public:
      void display()
      {
          cout<<width*height<<"n";
      }
      void read_input()
      {
          cin>>width>>height;
      }
};

int main()
{
    RectangleArea area; 
    
    area.read_input();
    area.Rectangle::display();
    area.display();
    
    return 0;
}
Posted by: Guest on February-02-2022

Code answers related to "Rectangle Area hackerrank in c++"

Browse Popular Code Answers by Language