假设我有一个定义如下的类
class foo
{
char [10] bar;
}
假设没有填充/打包,在64位环境中与32位环境中相比,这个类的大小会有什么不同。
我相信该类的64位版本的长度将增加4个字节,因为:
- The class must contain a char* in order to point to the start of the array bar
- an char* is 8 bytes in a 64 bit environment vs 4 bytes in a 32 bit environment
我说得对吗?
谢谢
A further question about how arrays actually work If there is no pointer stored when you declare an array, how come you can get an address out of the array name and do things like bar[0], bar[1], etc?