Skip to main content

2.5) Primitive Data Types of C++: Boolean Values


  • Type bool represents a boolean (true or false) value
  • Literal values for bool are actually called true and false (without quotes - they are not strings!)
  • Integer values are converted implicitly to boolean values where necessary: non-zero integers become true, zero becomes false
  • bool values are converted implicitly to integers where necessary: true becomes 1, false becomes 0
  • When outputting a bool value to a stream, true is output as 1 and false is output as 0 (use the showbool manipulator to output the strings "true" or "false" instead)