void Test2()
{
int c=8;
int b=7;
int d=9;
int *a;
a = &b;
a+=sizeof(int); //I supposed that *a should points on variable d after this
cout << "b\t" << &b << "\t" << b << endl;
cout << "a\t" << a << "\t" << *a << endl;
cout << "c\t" << &c << "\t" << c << endl;
cout << "d\t" << &d << "\t" << d << endl;
}
我认为*a应该指向变量d,因为b和d(如我所想)位于局部变量堆栈附近。但是 *a 指向另一个地址,所以*a != d 我的问题是为什么会这样?它是 Visual Studio 2010 的功能还是其他什么?