Basics
Your system
- you can inspect your system by using
lscpu
lstopo
C++ types
Exercise 0: Sizeof
Write a program to check the size of different data types:
You can use the sizeof()
operator
char
,bool
,int
,float
,double
,std::vector<double>
,void*
- Write your own struct/class with different memembers with different types and check the size your datastructure
- Try to swap the member order, does anything change?
Exercise1: Alignment
Write a program to check the alignment of different data types:
You can use the sizeof()
operator
char
,bool
,int
,float
,double
,std::vector<double>
,void*
- Write your own struct/class with different memembers with different types and check the size your datastructure
- Try to swap the member order, does anything change?
You can also use this code to easily inspect sizeof()
and alignof()
: code