C++ online Test 一题# JobHunting - 待字闺中
h*g
1 楼
template
class Foo
{
T tVar;
public:
Foo(T t) : tVar(t) { }
};
class FooDerived : public Foo { };
FooDerived fd;
What is preventing the above code from being legal C++?
A.
The initialization of tVar occurs outside the body of Foo's constructor.
B.
FooDerived uses the non-C++ type std::string.
C.
tVar is a variable of an unknown type.
D.
FooDerived is a non-template class that derives from a template class.
E.
A constructor must be provided in FooDerived.
为啥E 是正确的呢?
class Foo
{
T tVar;
public:
Foo(T t) : tVar(t) { }
};
class FooDerived : public Foo
FooDerived fd;
What is preventing the above code from being legal C++?
A.
The initialization of tVar occurs outside the body of Foo's constructor.
B.
FooDerived uses the non-C++ type std::string.
C.
tVar is a variable of an unknown type.
D.
FooDerived is a non-template class that derives from a template class.
E.
A constructor must be provided in FooDerived.
为啥E 是正确的呢?