Virtual Methods or Function Pointers
问题 When implementing polymorphic behavior in C++ one can either use a pure virtual method or one can use function pointers (or functors). For example an asynchronous callback can be implemented by: Approach 1 class Callback { public: Callback(); ~Callback(); void go(); protected: virtual void doGo() = 0; }; //Constructor and Destructor void Callback::go() { doGo(); } So to use the callback here, you would need to override the doGo() method to call whatever function you want Approach 2 typedef