我已经定义了一个模板类,像这样:是否有可能有一个非模板类子类的模板类?
template <class T>
class Command {
public:
virtual T HandleSuccess(std::string response) = 0;
virtual std::string FullCommand() const = 0;
// ... other methods here ...
};
威尔C++允许我创建一个模板类的非模板子类?我的意思是我可以做这样的事情:
class NoopCommand : public Command<NoopResult> {
public:
NoopResult HandleSuccess(std::string response);
std::string FullCommand() const;
// ... other methods here ...
};
至于是不是为我工作,因为它说,下面的虚函数是不确定的:
T admix::Command<T>::HandleSuccess(std::string) [with T = admix::NoopResult]
std::string admix::Command<T>::FullCommand() const [with T = admix::NoopResult]
我如何具体界定他们给定的T?
这是由编译器或链接器发出的错误吗? – 2009-10-26 01:17:10
错误来自编译器。 – 2009-10-26 01:18:03
什么编译器和版本?在编译器上我尝试了(gcc 4.2.1 for Darwin),它为我编译干净。 – 2009-10-26 01:22:48