其他分享
首页 > 其他分享> > QVector和vector的隐式共享

QVector和vector的隐式共享

作者:互联网

QVector

  QVector<int>  vecA;

  QVector<int>  vecB;

  vecA.push_back(1);

  vecA.push_back(10);

  
  vecB= vecA;       cout<<"&vecA.at(0) : "<<&vecA.at(0)<<endl;   cout<<"&vecB.at(0) : "<<&vecB.at(0)<<endl;

   QVector<int>  vecC;

   vecA.setSharable(false);

   vecC = vecA;

   cout<<"&vecA.at(0): "<<&vecA.at(0)<<endl;

   cout<<"&vecC.at(0): "<<&vecC.at(0)<<endl;

  当禁用隐式共享之后,元素的地址就不再一样了。

Vector

 

参考链接:https://blog.csdn.net/hai200501019/article/details/11713519

标签:cout,vecA,QVector,越界,vector,共享,隐式
来源: https://www.cnblogs.com/hik-wxy/p/14893489.html