Posted: Sun Mar 17, 2013 9:26 pm Post subject: RE:Switch-Cases and enums
exit isn't a statement in C/C++. In the code Insectoid posted, it's a boolean variable initialized in the initializer part of the for loop.
Note that 'exit' can also refer to the exit() method (available on Unix/Linux systems, I don't know about Windows). However, method invocations always have round brackets attached in C/C++, which means that referring to 'exit' without '()' must be referring to a variable.
Sponsor Sponsor
Cancer Sol
Posted: Mon Mar 18, 2013 12:05 pm Post subject: Re: Switch-Cases and enums
Oh I see... what does ! do that's beside exit in the for loop?
code:
for (bool exit = false; !exit;){
switch (something){
case 1:
exit = true;
break;
}
}
DemonWasp
Posted: Mon Mar 18, 2013 12:28 pm Post subject: RE:Switch-Cases and enums
! is the unary not operator. With booleans, it flips the value: true becomes false, false becomes true.
If you're going to learn C++, you really need to read a book that will take you through all of this.
Cancer Sol
Posted: Wed Mar 20, 2013 6:57 pm Post subject: Re: RE:Switch-Cases and enums
DemonWasp @ 3/18/2013, 12:28 pm wrote:
! is the unary not operator. With booleans, it flips the value: true becomes false, false becomes true.
If you're going to learn C++, you really need to read a book that will take you through all of this.
Well.. I started studying them on the internet
I really gotta learn all those lol, just some new stuff I learned can shorten my code a lot, and make it easier to read.