Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++基础语法54存疑 #149

Open
LdleFlowersLand opened this issue Mar 23, 2024 · 0 comments
Open

C++基础语法54存疑 #149

LdleFlowersLand opened this issue Mar 23, 2024 · 0 comments

Comments

@LdleFlowersLand
Copy link

//使用前面的类ADT,创建一个数组
auto adt_p = new ADT[10];
cout << *((int*)(adt_p)-2)<< endl; 
cout << *((int*)(adt_p)-1)<< endl;

结果为:
10
0
说明并不是在数组前分配4个字节,而是分配了8(2*sizeof(int))个字节

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant