Can someone point me the to the implementation of sizeof operator in C++ and also some description about its implementation.
sizeof is one of the operator that cannot be overloaded.
So it means we cannot change its default behavior?
c++sizeof
Can someone point me the to the implementation of sizeof operator in C++ and also some description about its implementation.
sizeof is one of the operator that cannot be overloaded.
So it means we cannot change its default behavior?
Best Answer
sizeof
is not a real operator in C++. It is merely special syntax which inserts a constant equal to the size of the argument.sizeof
doesn't need or have any runtime support.Edit: do you want to know how to determine the size of a class/structure looking at its definition? The rules for this are part of the ABI, and compilers merely implement them. Basically the rules consist of
However, ABIs are platform- and often vendor-specific, i.e. on x86 and (say) IA64 the size of
A
below will be different because IA64 does not permit unaligned data access.