Size of Compile-time Operator
Size of is a unary compile-time operator which returns the length of the operand, in bytes. The operand could be a variable that should be a constant or a data type.
Example:
#include <iostream.h>
main()
{
char ch;
cout<<sizeof ch;
cout<<sizeof(int);
}
The output is:
12
Note, to compute the size of a type, you have to enclose the type name in parentheses. This is not must for variable names. Size of operator is generally used to determine the lengths of arrays and structures whenever their sizes are not known to the programmer. That is also used to allocate dynamic memory to variables in during execution of the program.