what is the problem of this code in c++
template <typename T>
class Foo {
T tVar;
public:
Foo(T t):tVar() {}
};
class FooDerived: public Foo<st开发者_StackOverflow社区d::string> {};
FooDerived fd;
what is the problem of this code?
the problem is Foo does not have an empty C'tor - Foo(void), while FooDerived is trying to initialize the Foo with an empty C'tor (since it is the default..) so you will get a compilation error, since the compiler does not know how to create DerivedFoo()
精彩评论