course content

Course Content

Introduction to C++

sizeof(), auto, typedefsizeof(), auto, typedef

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:

cpp

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.

cpp

main.cpp

C++ also allows you to rename existing data types for yourself. This is what typedef is used for:

cpp

main.cpp

When compiled, the typedef line tells the compiler that MY_NEW_TYPE is just a double type.

Section 2.

Chapter 5