S**Y 发帖数: 136 | 1 question 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. FooDerived is a non-template class that derives from a template class.
B. tVar is a variable of an unknown type.
C. A constructor must be provided in FooDerived.
D. FooDerived uses the non-C++ type std::string.
E. The initialization of tVar occurs outside the body of Foo's const | d****z 发帖数: 53 | 2
FooDerived has no proper constructor, needs to write one
constructor.
a
oper
destructor.
Since it's a pure virtual function, should not be called in the destructor
illega
no
【在 S**Y 的大作中提到】 : question 1: : template : class Foo : { : T tVar; : public: : Foo(T t) : tVar(t) { } : }; : class FooDerived : public Foo { }; : FooDerived fd;
|
|