Jef*_*eff 1 virtual design-patterns private non-virtual-interface template-method-pattern
什么是可接受的术语(如果有的话),用于描述只能虚拟调用的方法以及基础中的其他方法?我偶尔会看到这被称为回调,但这似乎偏离了该术语的原始定义.我甚至不确定这是一种被称为模式的优点,但我正试图在评论我的代码时变得更加精确.谢谢您的帮助!
// Abstract class.
class A {
public:
void run() { while (call()) { /* ... */ } }
private:
virtual bool call() = 0;
};
// Completion/specialization of A.
class B : public A {
private:
// Standard term to indicate this pattern?
bool call();
};
Run Code Online (Sandbox Code Playgroud)
摘要:这似乎被称为非虚拟接口模式,这是模板方法模式的一个特例.感谢Nick和Steven的帮助!