我的C++代码C++:结构的大小?
#include <iostream>
using namespace std ;
struct Node {
int data ;
struct Node *next;
};
int main(){
struct Node *head = NULL;
struct Node *second = NULL;
cout << sizeof(struct Node);
}
输出到终端
16
是怎样的大小16? int的大小是4字节。 它是如何乘以4? 请任何人都可以给出详细的计算? 谢谢!
你的结构体包含不止一个int,加上填充/对齐。 – VTT
你能解释它是如何制作高达16字节的吗? –
*“int的大小是4字节。”* - 不要指望它总是正确的。也不要指望指针大小为0. – StoryTeller