I wrote a simple interface: (ICopyOnOperator.h)
template<typename T>
class ICopyOnOperator {
public:
virtual const T& operator=(const T& other) = 0;
ICopyOnOperator() = default;
ICopyOnOperator(const ICopyOnOperator& other) {
this->operator=((const T&)other);
}
};
It is supposed to automate calling the operator=
function when the copy constructor gets called.
In another class I derive from it: (Vao.h)
class Vao : public ICopyOnOperator<Vao> {
...
public:
virtual const Vao& operator=(const Vao& other) override {
return *this;
}
};
And when I compile my code, I get the 'unresolved external symbol' error. Do you have any idea why (I know what the error message means, but why does it happen?) or how to achieve my goal differently?
[EDIT]
To make it clear. The linker cannot find the ICopyOnOperator<class Vao>::operator=(class rhino::Vao const &)
method.
Full error message:
1>tester.obj : error LNK2019: unresolved external symbol "public: virtual class rhino::Vao const & __thiscall rhino::ICopyOnOperator::operator=(class rhino::Vao const &)" (??4?$ICopyOnOperator@VVao@rhino@@@rhino@@UAEABVVao@1@ABV21@@Z) referenced in function "public: __thiscall rhino::ICopyOnOperator::ICopyOnOperator(class rhino::ICopyOnOperator const &)" (??0?$ICopyOnOperator@VVao@rhino@@@rhino@@QAE@ABV01@@Z)