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