M
Michael DOUBEZ
arnuld a écrit :
Because that is what I mean: a const array of const string initialized
only once. Not that it make a lot of difference here.
In fact, I'd rather put this outside the function, in the global
namespace in order to find it more easily if a change is needed; by
example, correcting a typo or defining another language.
In this case, I would use static in order to preserve the namespace (in
a bigger project that is ).
No you didn't, you cleared cin 3 lines before and it was lost in the
flow of code :
<OP>
std::cout << "\t*Subtract 7 from it\n";
sleep(think_time);
std::cout << "\t*Subtract 3 from it\n";
sleep(think_time);
std::cin.clear();
std::cout <<"\tHow Much U Have Now :- ";
int think_num;
std::cin >> think_num;
...
</OP>
What I am basically saying is to do it JUST before reading so that on
rereading, you don't have to look for it:
int think_num;
std::cin.clear();
std::cin >> think_num;
....I guess it is a metter of taset but in this case, I prefer iterating on
the content of a table:
static char const* const instructions[]=
{"Add 10 to that number"
Looks okay to me but why use "static" in the array definition ?
Because that is what I mean: a const array of const string initialized
only once. Not that it make a lot of difference here.
In fact, I'd rather put this outside the function, in the global
namespace in order to find it more easily if a change is needed; by
example, correcting a typo or defining another language.
In this case, I would use static in order to preserve the namespace (in
a bigger project that is ).
I did, check again.
No you didn't, you cleared cin 3 lines before and it was lost in the
flow of code :
<OP>
std::cout << "\t*Subtract 7 from it\n";
sleep(think_time);
std::cout << "\t*Subtract 3 from it\n";
sleep(think_time);
std::cin.clear();
std::cout <<"\tHow Much U Have Now :- ";
int think_num;
std::cin >> think_num;
...
</OP>
What I am basically saying is to do it JUST before reading so that on
rereading, you don't have to look for it:
int think_num;
std::cin.clear();
std::cin >> think_num;