- C++ is a strongly typed language.
This means that every value has a specific type.
The meaning of a value is largely determined by its type.
A data type determines both the size
and the interpretation of a value.
For example, the int type means a signed integer value
of the natural machine size,
and unsigned int means the same size integer with no bit
reserved for sign.
Primitive types are those basic types
that are used in building other compounds types.
Primitives in C++ include integer types
for representing integer numerical values,
floating point types for representing real numerical values,
a Boolean type for representing true and false values.
C++ also provides literal values for true and false.
Compound types serve as containers for primitives
and other types.
An array is a contiguous sequential set of objects
of the same type.
Arrays are very powerful, flexible,
and have very low overhead.
They are also the basis of C strings
and the C++ STL container classes.
Although, C++ has no primitive string type,
a null-terminated array of characters is a special case
often called a C string,
and is treated as a string in many contexts.
A structure is a sequential set of objects of various types.
A structure may contain scalars, arrays
and even other structures and classes.
C++ classes are based on C structures.
Technically, a class is a structure that defaults
to private membership.
In practice, a class is a structure
that contains function members
as well as data members.
A union is a set of overlapping objects.
This allows a single compound object
to hold objects of various different types
at different times,
reusing the same space.
A pointer is an address that references an object
of a given type.
The pointer itself typically holds the address of the object
to which it points.
Pointers are strongly typed in C++,
the type of a pointer is used as the type
of the dereferenced value.
It's also used to determine the size
of increments, decrements,
and arithmetic operations on the pointer.
A reference is much like a pointer,
but with different semantics.
References are immutable,
once defined, they cannot be changed to refer
to a different object.
And references are accessed as aliases
without any syntactic indication
that it's a reference.
This allows for silent side effects
and should be used with great care.
C++ provides a number of fundamental data types
which may be used or extended for many purposes.
The rest of this chapter will cover these types
in greater detail.