我有一个这样定义的模板类:
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 专门定义它们?