我正在嘗試將動態足跡音頻合併到我的遊戲中。繼承人現在一些代碼:將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