Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Switch-Cases and enums
Index -> Programming, C++ -> C++ Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DemonWasp




PostPosted: 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
Sponsor
sponsor
Cancer Sol




PostPosted: 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




PostPosted: 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




PostPosted: 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 Razz
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.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 19 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: