I'm trying to do have Derived derive from Base:
class Base
{
public:
Base() {};
};
template <class T>
class Derived : public Base
{
public:
Derived::Derived()
{
}
};
This gives me the following error:
error C3254: 'Derived': class contains explicit override '{ctor}' but does not derive from an interface that contains the function declaration
note: see reference to class template instantiation 'Derived' being compiled
error C3244: 'Derived::Derived(void)': this method was introduced by 'Unknown>' not by 'Base'
I'm totally new to templates, what simple steps am I missing? This seems like a pretty basic thing.
You need to omit the "Derived::" prefix. You would only use it to refer to a symbol that was inherited, or injected into the namespace of the class Derived. So the only prefix that makes sense is "Base::" here. It has nothing to do with templates.
class Base
{
public:
Base() {};
};
template <class T>
class Derived : public Base
{
public:
Derived() {}
};
See a working Live Demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With