Rectangle Area

Sort by

recency

|

196 Discussions

|

  • + 0 comments
    class Rectangle{
        public:
        int height,width;
        void display(){
            cout<<width<<" "<<height<<endl;
        }
    };
    class RectangleArea: public Rectangle{
        public:
        void read_input(){
            cin>>width>>height;
        }
        void display(){
            cout<<(width*height);
        }
    };
    
  • + 0 comments

    include

    using namespace std;

    class Rectangle{

    public:
    int field_width;
    int field_height;
    

    void display(){ cout< class RectangleArea : public Rectangle{ public: void read_input(){ cin>>field_width; cin>>field_height; } int sum(){ return field_width * field_height; }
    };

    int main(){

    RectangleArea obj1;
    
    obj1.read_input();
    int value = obj1.sum();
    obj1.display();
    cout<<value<<endl;
    
    return 0;
    

    }

  • + 0 comments

    using namespace std;

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

    }
    void display()override
    {
     Rectangle::display();
     cout << width * height << endl; 
    }
    

    };

    int main() { RectangleArea rectangle1; rectangle1.read_input(); rectangle1.display(); return 0; }

  • + 0 comments
    class Rectangle {
    protected:
        int width;
        int height;
    
    public:
        void display() {
            cout << width << " " << height << endl;
        }
    };
    
    class RectangleArea : public Rectangle {
    public:
        void read_input() {
            cin >> width >> height;
        }
    
        void display() {
            cout << width * height << endl;
        }
    };
    
  • + 1 comment

    C++ 14

     class Rectangle{
         public:
         int w,h;
         void display(){
             cout<<w<<" "<<h<<endl;
         }
     };
     
     class RectangleArea : public Rectangle{
         public:
         void read_input(){
             cin >> w;
             cin >> h;
         }
         void display(){
             cout<<w*h;
         }
     };