sizeof 深入理解
sizeof你们觉得是什么呢。函数?其实是操作符。
wiki解释
In the programming languages C and C++, the unary operator ‘sizeof’ is used to calculate the sizes of datatypes, in number of bytes. sizeof can be applied to all datatypes, be they primitive types such as the integer and floating-point types defined in the language, pointers to memory addresses, or the compound datatypes (unions, structs, or C++ classes) defined by the programmer. sizeof is an operator that returns the size in bytes of the type of the variable or parenthesized type-specifier that it precedes as a size_t type value.
sizeof is an operator:sizeof是一个操作符。擦 这货居然是操作符。
最后一句我们可以得到的信息还有sizeof操作符的结果类型是size_t,它在头文件中typedef为unsigned int类型。该类型保证能容纳实现所建立的最大对象的字节大小。