I suppose not, but I just wanted to check - is there a way in C ++ to do something like the following? Obviously, when I try to do the following, I get an error based on the area around the bar.
void foo(Bar bar, int test = bar.testInt) { ... }
If the test value is not valid, you may find that:
test
void foo(Bar bar, int test = -1) { //assuming -1 is invalid if(test == -1) test = bar.testInt; //... }
If not, you can always use overloaded functions:
void foo(Bar bar, int test) { //... } void foo(Bar bar) { foo(bar, bar.testInt); }