关于string指针

string str("hello world");

string *pstr = &str;

cout << pstr[0] << endl;

cout << *pstr << endl;

本来以为psr[0]输出来的值是'h' 没有想到输出来的而是 hello world ,而且 *pstr输出的也是同样的值

很明显string组织数据的时候应该是链表

*ptr 和ptr[0]指向的是同一个地址 所以他们输出来的值是一样的

posted @ 2014-08-17 15:04  蝴蝶狼  阅读(2458)  评论(0编辑  收藏  举报