Question: Please explain step by step: Inheritance You are making a drawing application. The code you are given declares a Shape base class, and you are

Please explain step by step:

Inheritance You are making a drawing application. The code you are given declares a Shape base class, and you are making separate classes for each shape that your application is going to support. Inherit the Rectangle class from the Shape class and call its draw() method. Inherit using a colon and an access specifier.

#include

using namespace std;

class Shape

{

public:

void draw() {

cout << "Drawing...";

}

};

//inherit from Shape

class Rectangle

{

private:

int width;

int height;

public:

Rectangle(int w, int h): width(w), height(h) {

cout <

};

};

int main() {

int x, y;

cin>>x>>y;

Rectangle d(x, y);

//call the draw() method

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!