![]() |
|
[C] C++ boolean types .... - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] C++ boolean types .... (/showthread.php?tid=5909735) |
C++ boolean types .... - ThePolitician - Nov 19, 2018 Is anyone here who really can explain me how “boolean” work? And please give me some example if you can!!! Thanks! ThePolitician RE: C++ boolean types .... - 0xDEAD10CC - Nov 19, 2018 Code if (this.thread == a_joke)? RE: C++ boolean types .... - Shadow Reign - Nov 19, 2018 A Boolean, from my understanding is just a true or false. Yes or no. 0 or 1 Simple as that. it's used to determine if something is or isn't. RE: C++ boolean types .... - iTHX - Nov 20, 2018 if (5+5==10){ return true; } else { return false; } // if used productively then its used like this... int main(){ int age; bool isAble = false // able to drive initially false cout << "Age :" << endl; cin age; if (age >= 17){ isAble = true; } else if (age < 17){ isAble = false; } while(isAble){ cout << endl << "user is able to drive"; } while(!isAble){ cout << endl << "user unable to drive"; } return 0; } RE: C++ boolean types .... - 0xDEAD10CC - Nov 20, 2018 (Nov 20, 2018 10:15 AM)iTHX Wrote: if (5+5==10){ I don't see how that is productive because the expressions are bools too. Not sure what the while loops are for, they won't terminate by themselves. You also over-complicated a simple if-else statement. RE: C++ boolean types .... - Synode - Nov 20, 2018 either true or false nothing more RE: C++ boolean types .... - TCP - Nov 20, 2018 Remember that despite being a binary value, it is still of the size of a byte because it needs to be allocated in the memory RE: C++ boolean types .... - iTHX - Nov 20, 2018 (Nov 20, 2018 10:22 AM)0xDEAD10CC Wrote: I don't see how that is productive because the expressions are bools too. Not sure what the while loops are for, they won't terminate by themselves. You also over-complicated a simple if-else statement. i understand your point, i was just trying to find an excuse to use them in a basic, understandable program. i can do much better than this |