Member function

Feb 21, 2014 at 3:43am
Cans someone give me an example of an inline function that accepts two variables that sets two private member variables. Did i do something wrong there?
1
2
3
4
5
6

private:
int r1:
int r2:
public:
int Value(int w,int d){return w =r1, d= r2;}
Feb 21, 2014 at 4:10am
You can't return two values. Also the function type can be void instead of int because you don't need to return any values if you're just changing them.
Try this:
void Value(int w, int d) {r1 = w; r2 = d;}
Last edited on Feb 21, 2014 at 4:11am
Topic archived. No new replies allowed.