Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++]bool

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
superfirepig
Master Cheater
Reputation: 0

Joined: 07 Oct 2006
Posts: 313
Location: city of hackers

PostPosted: Wed Jan 23, 2008 11:02 am    Post subject: [C++]bool Reply with quote

Can anyone give me a definition of bool? I know it can break down a very long code to shorter lines but can anyone give me an example of when to use it and how to use it?
_________________
You don't have enough MP to f#@% me, please try again later
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Wed Jan 23, 2008 11:09 am    Post subject: Reply with quote

Bool is shorten from Boolean. I dont know whenever you are familar with Booleans but however they can just have two values. Either true or false.
They are not really usefull and dont know why they exist.

Code:
bool LoggedIn = true;

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
goldengold
Grandmaster Cheater Supreme
Reputation: -1

Joined: 11 Nov 2006
Posts: 1841
Location: -.-

PostPosted: Wed Jan 23, 2008 12:10 pm    Post subject: Reply with quote

Code:

bool female = true

_________________
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Wed Jan 23, 2008 12:50 pm    Post subject: Reply with quote

goldengold wrote:
Code:

bool female = true

bool female = true;

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Wed Jan 23, 2008 12:59 pm    Post subject: Reply with quote

Naablet wrote:
Bool is shorten from Boolean. I dont know whenever you are familar with Booleans but however they can just have two values. Either true or false.
They are not really usefull and dont know why they exist.

Code:
bool LoggedIn = true;


wut do u mean they're not really useful...
booleans are an easy simple way to get a true or false answer.
if you read some source code (for example some of Wiicaan's) they're obviously used a LOT.

_________________
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Wed Jan 23, 2008 1:10 pm    Post subject: Reply with quote

lurc wrote:
Naablet wrote:
Bool is shorten from Boolean. I dont know whenever you are familar with Booleans but however they can just have two values. Either true or false.
They are not really usefull and dont know why they exist.

Code:
bool LoggedIn = true;


wut do u mean they're not really useful...
booleans are an easy simple way to get a true or false answer.
if you read some source code (for example some of Wiicaan's) they're obviously used a LOT.


If used right they are usefull Razz

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Wed Jan 23, 2008 2:23 pm    Post subject: Reply with quote

A bool can have only two values either true(1) or false(0). It is most commonly used to print error messages. It can be very useful to use when your working on bigger programs that have lots of room for errors.
_________________

Earthbound = 31337
Back to top
View user's profile Send private message
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Wed Jan 23, 2008 2:25 pm    Post subject: Reply with quote

Booleans are mostly used for conditional statements. Some people use it as an array to represent binary.

Example:
Code:

-Create a loop
-Show a menu
1) Something
2) Something
3) Exit
-Get input
-Do your code

bool isGoing = true;

while (isGoing)
{
     // Display menu and get input
     ...
     switch (<variable>)
     {
          // Insert for case 1 and 2
          case 3:
          isGoing = false; // this will end the loop
          break;
     }
}


Just for fun, you can use cout.setf(ios_base::boolalpha); to display the boolean as true or false instead of 1 or 0. You would put that statement in the beginning of main and only once.

Code:

#include <iostream>
int main (int argc, char *argv[])
{
     std::cout.setf(std::ios_base::boolalpha)
     ...
     return 0;
}
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Jan 24, 2008 6:55 pm    Post subject: Reply with quote

Booleans are probably one of the most used variable types.

Naablet, you should really stop posting just your opinion in all of your posts. You seem to say "not really useful" to a lot of things. That is your opinion, and your code style isn't the best either.

superfirepig, as the others have pointed out already, a boolean is a true / false variable type. The value can be seen as 0 or 1 as well. 0 being false, 1 being true.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
nox
Expert Cheater
Reputation: 0

Joined: 09 Apr 2007
Posts: 227
Location: brooklyn

PostPosted: Sun Jan 27, 2008 6:36 pm    Post subject: Reply with quote

Naablet wrote:
goldengold wrote:
Code:

bool female = true

bool female = true;

fucking idiot

Naablet wrote:

They are not really usefull and dont know why they exist.

fucking idiot
Back to top
View user's profile Send private message
Spawnfestis
GO Moderator
Reputation: 0

Joined: 02 Nov 2007
Posts: 1746
Location: Pakistan

PostPosted: Mon Jan 28, 2008 6:07 am    Post subject: Reply with quote

nox wrote:
Naablet wrote:
goldengold wrote:
Code:

bool female = true

bool female = true;

fucking idiot

Naablet wrote:

They are not really usefull and dont know why they exist.

fucking idiot


fucking genius

_________________

CLICK TO HAX MAPLESTORAY ^ !!!!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Jan 28, 2008 2:28 pm    Post subject: Reply with quote

Fucking locked.

Just sounded good. Anyway, question was answered, things went into the wrong direction. Yadda yadda.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites