Hi,
I have a Base class, a class VDer that virtually inherits from it, and a Final class that inherits from VDer.
The Base class only has a constructor which has a parameter.
class Base {
public:
Base(const string& par) : par(par) {}
private:
string par;
};
class VDer : public virtual Base
{
public:
VDer1(const string& par) : Base(par) {}
};
class Final : public VDer
{
public:
Final(const string& par) : VDer(par) {}
};
The compiler complains that "no matching function for call to 'Base::Base()'" .
Why does the compiler want to call Base constr without parameter? How can this be solved?
(NOTE: Base must not have a constructor without parameter).
I know that virtual inheritance may not be the best option, but I would like to know the answer to this problem anyway.
Thanks in advance,
Harinezumi
I have a Base class, a class VDer that virtually inherits from it, and a Final class that inherits from VDer.
The Base class only has a constructor which has a parameter.
class Base {
public:
Base(const string& par) : par(par) {}
private:
string par;
};
class VDer : public virtual Base
{
public:
VDer1(const string& par) : Base(par) {}
};
class Final : public VDer
{
public:
Final(const string& par) : VDer(par) {}
};
The compiler complains that "no matching function for call to 'Base::Base()'" .
Why does the compiler want to call Base constr without parameter? How can this be solved?
(NOTE: Base must not have a constructor without parameter).
I know that virtual inheritance may not be the best option, but I would like to know the answer to this problem anyway.
Thanks in advance,
Harinezumi
Comment