我有以下情况: -
template <typename T>
class Base {
public:
virtual void someFunc() {}
};
class Derived : public Base<int>,
public Base<float> {
public:
virtual void someFunc() {
// do something different if Base<int> than if Base<float>
}
};
Derived *d = new D();
Base<int>* b1 = (Base<int>*) d;
Base<float>* b2 = (Base<float>*) d;
b1->someFunc();
b2->someFunc();
我希望能够区分这两个函数调用。或者换句话说,用不同的函数体覆盖两个基本函数。