Attempt in visual studio.
Find errors and rewrite the code and show output
C++
#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;}
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;
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here