| fenderist (2) | |||
|
I have this code that works fairly well, but depending if I put an extra while loop or not I get errors: hw7.cpp:34: error: ‘selected’ was not declared in this scope hw7.cpp:36: error: ‘first’ was not declared in this scope hw7.cpp:37: error: ‘second’ was not declared in this scope hw7.cpp:43: error: ‘second’ was not declared in this scope
Why am I getting the error? Is it because the compiler thinks that it might never get to that part of the code? | |||
|
|
|||
| bluezor (298) | |
|
Not sure but maybe the class isn't set up properly? Also don't put the srand(int)time(0)); inside the while loop. Put it once at the start of the code or else if you seed it every time it goes through a while loop you will get unwanted results.
| |
|
|
|
| ne555 (4038) | |||
|
If you declare something inside a while, for, if, function, it survives only in that scope. My guess is that you have
Put the lines that you're getting the errors (34 to 43) | |||
|
|
|||