小编Jen*_*ger的帖子

重载abstract operator =时Clang链接器错误

VisualStudio 2013编译器处理以下代码就好了,但是clang 5.0和6.2给我一个链接器错误:

#include <memory>

using namespace::std;

class IBase
{
public:
    virtual IBase& operator=(const IBase& other) = 0;
};

class Base : virtual public IBase
{
public:
    Base& operator=(const IBase& other) override
    {
        const Base& b = dynamic_cast<const Base&>(other);
        return *this = b;
    }

    virtual Base& operator=(const Base& other)
    {
        return *this;
    }
};

class IDerived : virtual public IBase
{
};

class Derived : public IDerived, public Base
{
public:
    using Base::operator=;

};

int main(int argc, const char * …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance operator-overloading assignment-operator c++11

6
推荐指数
1
解决办法
258
查看次数