Help with classes

Trying to have a user input 2 digits to calculate area. The program doesn't behave properly.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <iostream>
using namespace std;
class CRectangle
{
int x,y ;
public:
   void set_values (int a ,int b){
        x = a , y = b;
    }
   int area () { return(x*y);
    }
};

int main ()
{
int a, b;
CRectangle rect;
cout<<"Enter two digits"<< endl;
cin >>a,b ;
rect.set_values(a,b);
cout << "the area is"<< rect.area();
return 0;
}
Last edited on
Line 19

to:

cin >> a >> b;
line 19. cin >>a >>b ;
thank you both!!
Topic archived. No new replies allowed.