C++ Base Data Types

The base (or basic - not to be confused with the language) data types in C++ are (ordered smallest to largest):

You are already familiar with the types int and float. An integer is any whole number (... -3, -2, -1, 0, 1, 2, 3...). Keep in mind that an int can only hold a finite range of integers, which depends on the Qualifiers used (more in a bit). A float is a floating-point number that uses a decimal point to capture a fractional number.

A double is also a floating point number, but can store a value of much greater magnitude with greater precision than a float value. BeOS uses the IEEE standard for floating-point numbers.

A char is actually much like an integer, as it really stores a number, but that number is a representation of a character (ASCII, by default).

A bool is a boolean value (true or false), which is also, actually an integer. You may represent a type bool value as "false" (or the number zero), or as "true" (or any non-zero value).

The various flavors of bool, char, int, and enum (not discused here) are referred to by Stroustrup (The man who wrote C++) collectively as "integral types". Also note: a UNICODE value won't fit into a char, though some UTF8 values will.

There are also "Qualifiers" that you must know for some of the above types. These are:

This gives a possible 21 definitions (22 when including type bool). But you'll soon be amazed at the power these basic 22 definitions give the programmer.

Now for a short talk on naming variables.