Variables and Fundamental Types
Declaring and Initializing Variables
Before using any variable, two things must happen: it is declared (so that the compiler knows the variable’s name and type), and it is initialized (so that the…
Integer Types
There are several integer types available in C++. These types vary by size and by whether they can represent negative numbers. As a beginner, you just need to k…
Floating-Point Types
Floating point types store numbers that contain a fraction of a whole number. Examples include 3.14, negative 0.5, and 0.001. There are two floating point types…
Characters and Boolean Values
C++ has two relatively simple, but perhaps interesting because of their daily usability, types: char (single character) and bool (true and false). Both are ofte…
Signed and Unsigned Types
Signed and Unsigned Types in C++C++ integer types can be signed or unsigned.The difference sets whether or not negative values are permitted and how you go abou…
Fixed-Width Integer Types
The fundamental integer types like int, long, and long long are not guaranteed to have the same sizeof() on different systems. For when you want an integer of e…
Constants with const and constexpr
The typical behavior for a variable in C++ is that its value can be changed; often the value is known at the time it is written and never needs to be changed ag…
Type Inference with auto
You can get tired of explicitly naming your variable’s type for each and every thing. Let the auto keyword guide you and have your compiler determine it for you…
Variable Scope and Shadowing
Each variable exists in a region of the program where the variable name is known. This region is known as its scope. If an inner scope defines a variable with t…