易采站长站为您分析C++编程中__alignof 与__uuidof运算符的使用,是C++入门学习中的基础知识,需要的朋友可以参考下
__alignof 值与基本类型的 sizeof 的值相同。但是,请考虑该示例:
__alignof 运算符
C++11 引入 alignof 运算符,该运算符返回指定类型的对齐方式(以字节为单位)。为实现最大的可移植性,应使用 alignof 运算符,而不是特定于 Microsoft 的 __alignof 运算符。
返回一个 size_t 类型的值,该值是类型的对齐要求。
语法
__alignof(
type
)
备注
例如:
| Expression | 值 |
|---|---|
| __alignof( char ) | 1 |
| __alignof( short ) | 2 |
| __alignof( int ) | 4 |
| __alignof( __int64 ) | 8 |
| __alignof( float ) | 4 |
| __alignof( double ) | 8 |
| __alignof( char* ) | 4 |
__alignof 值与基本类型的 sizeof 的值相同。但是,请考虑该示例:










