The results of the sizeof operator are partially dependent on the type of action:
The result of a sizeof operation on a char or an expression of type char is 1;
Performs a sizeof operation on a reference type to obtain the size of the space occupied by the referenced object;
The size of the space occupied by the pointer itself is obtained by performing the sizeof operation on the pointer;
Performing the sizeof operation on the dereference pointer gets the size of the space occupied by the object pointed to by the pointer, and the pointer does not need to be valid;
Performing the sizeof operation on an array results in the size of the total space occupied by the arrays, equivalent to all elements of the array performing the sizeof operation once and summing the resulting result;
Performing a sizeof operation on a string object or a vector object returns only the size of the fixed part of the type, and does not calculate how much space the elements in the object occupy.
C + + prime:sizeof operators