PROGRAMMING LANGUAGE: C++ SUBJECT: OOP Task: Find errors in the following code and rewrite a correct version of code with outputs. #include using namespace std; class CRectangle { int width. height;...



PROGRAMMING LANGUAGE: C++



SUBJECT: OOP




Task: Find errors in the following code and rewrite a correct version of code with outputs.









#include


using namespace std;


class CRectangle {


int width. height;


public:


void set_values (int, int);


int area () {return (width * height);}


};


void CRectangle::set_values (int a, int b) {


width = a;


height = b;


}


int main () {


CRectangle a,*b,*c;


c= a;


a.set_values (1,2);


b= new CRectangle;


c=&b;


c->set_values (3,4);


cout < "a="" area:="" "="">< c-="">area() <>


cout < "*b="" area:="" "="">< a.area()=""><>


c->set_values (5,6);


cout < "*b="" area:="" "="">< b.area()=""><>


delete b;


return 0;


}




Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here