Values and Their Types

In C++, every value, at every moment in its lifetime (during program execution), is characterized by its type. C++ variables are associated with their types at the time of definition. The type describes three characteristics of the value:

  • the size of the values of that type in computer memory

  • the set of values that are legal for the type (the method of interpretation of the bit pattern that represents the value of that type)

  • the set of operations that are legal on the values of that type

For example, the values of type int on my machine are allocated four bytes, and the set of legal values ranges from −2,147,483,648 to +2,147,483,647. The set of legal operations includes assignment, comparisons, shifts, arithmetic operations, ...

Get Core C++ A Software Engineering Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.