小编sho*_*mit的帖子

为什么我无法创建唯一指针

尝试创建唯一指针时出现 c2664 错误

我确实编写了复制构造函数和赋值运算符,但仍然不断收到 2664 错误

class UndoCopyPaste : public UndoRedo
    {
    private:
        Container containerValue;
        bool valid;
    public:
        UndoCopyPaste() = default;
        UndoCopyPaste(Container* cont, std::string type);
        UndoCopyPaste(Container trans, Container* cont, std::string type);
        
    };
    
    class UndoRedo
    {
    private:
        std::string type;
    protected:
        Container* container;
    public:
        UndoRedo() = default;
        UndoRedo(Container* cont, std::string undoType);
    };
    
    std::unique_ptr<UndoCopyPaste> undoCopyPastePointer = std::make_unique<UndoCopyPaste>(new UndoCopyPaste()); // error C2664: 'UndoCopyPaste::UndoCopyPaste(UndoCopyPaste &&)': cannot convert argument 1 from '_Ty' to 'const UndoCopyPaste &'
Run Code Online (Sandbox Code Playgroud)

c++ c++11 c++14

2
推荐指数
1
解决办法
91
查看次数

标签 统计

c++ ×1

c++11 ×1

c++14 ×1