![]() |
#2
wp2319572015-06-29 15:58
|

#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main()
{
string a = "long";
cout << &a << endl;
cout << (void*)&a[0];
system("pause");
return 0;
}
#include<string>
#include<cstdlib>
using namespace std;
int main()
{
string a = "long";
cout << &a << endl;
cout << (void*)&a[0];
system("pause");
return 0;
}
输出结果:
只有本站会员才能查看附件,请 登录
问题:1.a与a[0]的地址不是应该是一样的么,为啥输出的结果不一样?(难道我输出&a,是指地址的地址么)
2.为什么&a与&a[0]的地址总是相差4?(运行很多遍都是相差4)