I've been scratching my head at this one and can't figure out how to get the do to be declared. If any one can give me an example on how to get the do to "do it's job" i'll be much appreciated.
#include <bits/stdc++.h>
usingnamespace std;
class Numbergen {
int theNumber;
public:
void PlayGame(int tries=0) {
char answer;
do {
theNumber = rand() % 10 + 1;
cout << "I'll try to guess a number between 1 and 10.\n"
<< "is " << theNumber << " your number?(y/n) ";
++tries;
cin >> answer;
if ( (answer|0x20) == 'y' ) {
cout << "I knew I could do it! It only took me " << tries << " tries.\n";
}
else cout << "it appears I was wrong, i'll try again... " << endl;
} while ( answer != 'y');
}
};
int main(int argc, char **argv)
{
(new Numbergen())->PlayGame();
return 0;
}