Ale*_*rty 1 c++ pointers vector
我很好奇在这种情况下如何处理数据:
chapterlist.clear();
cScene newscene;
newscene.name = "Laura does something.";
newscene.words = 432;
newscene.pov = "Laura";
cChapter newchapter;
newchapter.scenelist.push_back(newscene);
chapterlist.push_back(newchapter);
Run Code Online (Sandbox Code Playgroud)
chapterlist是一个cChapter向量.
我正在创建一个新的cScene对象,并将其推送到新cChapter对象的scenelist向量,然后我将其推送到chapterlist.
我的问题是:当我将对象推送到向量时,是否所有数据都被复制到向量中,而旧数据在作用域结束时从堆栈中被销毁?
或者是其他事情发生了什么?
PS:我讨厌指针,就像很多人一样.