// classes example
#include <iostream>
usingnamespace std;
class CRectangle {
int x, y;
public:
void set_values (int,int);
int area (void);
};
void CRectangle::set_values (int a, int b) {
x = a;
y = b;
}
int CRectangle::area (void) {
return (x+y);
}
int main () {
CRectangle rect;
int a,b,num;
cout << "insert numbers a,b; ";
cin >> a,b;
rect.set_values (a,b);
num = rect.area();
cout << "area: " << num << endl;
system("Pause");
return 0;
}
The comma operator works by first evaluating the first operand, ignoring the return value, then it evaluates and returns the value of the second operand.
In your code cin >> a is the first operand and b is the second operand.