string str("hello world");

string *pstr = &str;

cout << pstr[0] << endl;

cout << *pstr << endl;

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

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

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

相关文章:

  • 2021-12-25
  • 2021-06-28
  • 2021-06-27
  • 2021-09-24
猜你喜欢
  • 2021-03-29
相关资源
相似解决方案