1
什么叫从一个类继承与相同的方法名3个基类匹配方法的最佳方法相匹配的方法呢?我想打电话从一个单一的调用这些方法,不知道它甚至有可能呼叫从继承类
template<typename T>
class fooBase()
{
void on1msTimer();
/* other methods that make usage of the template */
}
class foo
: public fooBase<uint8_t>
, public fooBase<uint16_t>
, public fooBase<float>
{
void onTimer()
{
// here i want to call the on1msTimer() method from each base class inherited
// but preferably without explicitly calling on1msTimer method for each base class
}
}
有没有办法做到这一点? 感谢
如果你想打电话给三个不同的功能,你*有*告诉编译器你想调用哪三个函数。 –
一种选择是所有基类从事件派发几乎继承,并注册自己的实现施工过程中,调度员。然后,派生最多的类可以通过调度器调用函数列表。 –