我正在尝试将动态足迹音频合并到我的游戏中。继承人现在一些代码:将unique_ptr矢量指定给矢量C++
class MyClass
{
vector< unique_ptr <Sound> > footstep_a;
vector< unique_ptr <Sound> > footstep_b;
vector< unique_ptr <Sound> > footstep_c;
vector<Sound> currentfootsteps;
}
所以基本上我想要做的就是分配footstep_载体之一currentfootsteps,这样我可以再有:
if(walkingarea == a)
currentfootsteps = a;
else ......
我试着做以下,但它只是抛出了关于向量和这样的百万错误:
if (walkingarea == a)
currentfootsteps.clear();
for(int i = 0; i < footstep_a.size(); i++)
currentfootsteps.push_back(footstep_a[i]);
谁能帮助我?
您正将'std :: unique_ptr <>'推回到'Sound'对象的向量中。这就是你遇到错误的原因。 – 0x499602D2