If it's necessary to find out how much memory a type uses,
you can use the sizeof
operator, which returns the
amount of memory need in bytes. (8 bits per byte) Altho it is
technically an operator, everyone writes it as if it was a
function. For example,
cout << sizeof(int);would print 4 on many current compilers because that is the most common (Dev C++, MS Visual Studio, Borland C++Builder, gcc, ...). In fact, many programs simply make some assumptions about the size of variables. It is common to assume they are 32, but if you want to write for maximum portability, it is better to use sizeof.
The single operand (argument) to sizeof is either a type or a variable.