Class C {
struct Something {
string s;
// Junk.
}
// map from some string to something.
map<string, Something> map;
// Some more code:
const Something *Lookup(string k) const {
const something *l = SomeLookUpFunction();
cout << l;
cout << &l->s;
cout << l->s;
return l;
}
}
// Some Test file
const C::Something *cs = C::Lookup("some_key");
cout << cs;
cout << &cs->s;
cout << cs->s;
奇怪的是这个输出:
* 对于查找功能:
0x9999999
0x1277777
some_string
* 对于测试代码
0x9999999
0x1277777
0000000000000000000000000000000000000000000 ....
在测试文件中,它给出了一个很长的零字符串,但地址是相同的。知道可能出了什么问题吗?