Question: #include using namespace std ; class Rectangle { private : int width , length ; public : Rectangle () { width=1; length =2; cout <

#include

using namespace std ;

class Rectangle {

private :

int width , length ;

public :

Rectangle () {

width=1; length =2;

cout << "Hello world !!! " << endl ;

}

void set ( int w, int l ) { width = w; length = l ;}

int getWidth () {return width ;}

int getLength () {return length ;}

void printArea (){

cout << "Area = "<< width*length << endl ;

}

}; // end Rectangle class

int main () {

Rectangle r1 ;

r1.printArea ();

return 0;

}

Add another constructor that takes two parameters and assigns those values to width and length.

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!