C++ Tutorial #8 — More data types, integreation with if, and review


Topics Discussed: More data types, integrating said data types with if, and the start of a review seen in the next section.

Source Code Available Here.


Strings
Strings are an extremely important data type in C++ because they can hold literally anything. This is extremely useful for data sanitation. The best way to think of a C++ string is to have a strong understanding of how they’re implemented. If we’re going to explicitly set a string equal to a value, we can do so like this:
string stringName = "This is the value of the string";


bool
Bools are variables that hold a value of being either true (1) or false (0). These values cannot be seen as an actual number, but will evaluate to one in boolean mathematics (covered later). Bool variables default to “false” if you don’t specify what they are explicitly:


bool variablename; // initial value is set to false
bool variableName=true; //set to true