Course Content
Introduction to C++
The variable's size is the amount of memory reserved by the compiler.
Depending on the variable type, the compiler reserves a certain number of bytes of your PC's memory.
The sizeof()
function allows you to determine the size of your variable or data type in bytes.
For example:
main.cpp
C++ allows you to select a type with an exact number of bits. For example, data types int8_t
, uint8_t
, int16_t
, uint16_t
, etc.
To use them, you need to include the "cstdint"
header file.
We can also force the compiler to determine the variable type using auto independently
.
main.cpp
C++ also allows you to rename existing data types for yourself. This is what typedef
is used for:
main.cpp
When compiled, the typedef
line tells the compiler that MY_NEW_TYPE
is just a double
type.
Section 2.
Chapter 5