i have a question whats a bool and what does it do i read it but it dont make snes to me
i have a question whats a bool and what does it do i read it but it dont make snes to me
bool returns true or false depending on the condition
for example, since i is 0 it will return true (in otherwords 1), otherwise it would return 0 if false.
*Code tags finished by kermi3 (you forgot the bottom one)Code:foo() { int i=0 if( i==o)return true; else return false; }
Last edited by noob2c; 08-02-2003 at 06:00 PM.
Actually, compiling for windows, BOOL is either TRUE or FALSE (it's an enum), whereas bool is true or false (bool, true, false are C++ keywords).Originally posted by gcn_zelda
bool is TRUE or FALSE...
A boolean variable (bool) has only one of 2 values, it is either true or false.
bool is a variable type, and variables of type bool can have one of two values: true or false. Here is an example:
Code:#include<iostream> using namespace std; int main() { bool answer; answer = false; if(answer == true) cout<<"You correctly answered the question.\n"; else cout<<"You're answer was incorrect.\n"; return 0; }
oooo so what ur saying u need bool to figure out a true or false answer in the computer world right?
was that supposed to be some kind of Sarcasm oooooooOriginally posted by Joe100
oooo so what ur saying u need bool to figure out a true or false answer in the computer world right?
nope its just that im trying to understand everything i always say oooooooo i dunno why
It's a type of variables that can store one of two possible values: a bool variable can either have the value true or false (be true or false).
It isn't that much different from a a type like int. The only thing that might be strange at first is that it doesn't store a number but... uhm...one of two possible words: true or false. But don't get this wrong, it's not a string or something like that. It's not a numeric type either, but close to it.
somebool would be false because a != b. That means there will be no ouput from this example code unless you set a=b.Code:int a, b; bool somebool; a = 1; b = 2; somebool = (a==b); if (a==b) { cout << "(a==b) == true" << endl; }; if (somebool) { cout << "(somebool) == true" << endl; };