【发布时间】:2016-07-26 02:19:09
【问题描述】:
似乎在 vector<unique_ptr<UserInterface>> 中使用 unique_ptr 时出现错误说明:
Error 1 error C2280: 'std::unique_ptr<UserInterface,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)' : attempting to reference a deleted function c:\pr...ude\xmemory0 593 1 Win32Project1
看起来,没有配置允许我存储指向 UserInterface 类的 [智能] 指针,该类具有简单的结构:
#define InterfaceContruct vector<unique_ptr<UserInterface>>
class UserInterfaceMgmt
{
public:
UserInterfaceMgmt();
~UserInterfaceMgmt();
InterfaceContruct Interface;
void AddUIElement();
void RemoveUIElement();
void DrawInterface();
void MoveElement();
private:
};
即使没有调用任何函数,也会出现错误(InterfaceContruct Interface; 已实例化)我尝试将复制构造函数放入 private,但它仍然存在。
.cpp 文件是:
#include "stdafx.h"
#include "UserInterfaceMgmt.h"
UserInterfaceMgmt::UserInterfaceMgmt()
{
}
UserInterfaceMgmt::~UserInterfaceMgmt()
{
}
void UserInterfaceMgmt::DrawInterface(){
for (UINT i = 0; i < Interface.size(); i++)
{
Interface[i]->Draw();
}
}
【问题讨论】:
-
该错误消息的实例化回溯是什么?
-
你的“UserInterface”类是什么样子的?
标签: pointers c++11 vector game-engine copy-constructor