#include <iostream>
using namespace std;
template <typename T>
class Base {
public:
void fun() {
cout << "Base::fun" << endl;
}
void doSomething() {
T* pT = static_cast<T*>(this);
pT->fun();
}
};
class Drive : public Base<Drive> {
public:
void fun() {
cout << "Drive::fun" << endl;
}
};
class MostDrive : public Drive {
public:
void fun() {
cout << "MostDrive::fun" << endl;
}
};
int main() {
MostDrive obj;
obj.doSomething();
return 0;
}