D should pass the constructor argument to C , since you are not using default constructors.
class D : public C { public: template <typename T> D (T t) : C(t) {} float area () { } };
The reason for the error is that you are trying to build D with a parameter, but you did not specify any constructor that would allow you to do this. In addition, you must pass the parameter to C , otherwise the compiler will use the default C constructor.
The compiler error message can be analyzed as follows.
test.cpp:56:8: error: no matching function for call to 'D::D(A&)'
The compiler complains:
D d(a);
And that he cannot understand how to construct D when transferring something like A
He then presents two options for the constructors that he knows about:
test.cpp:44:7: note: D::D() test.cpp:44:7: note: D::D(const D&)
And he points out that for everyone there is a reason why he cannot use it. For the first, he does not accept any arguments. For the second, he cannot convert something of type A to type D
source share