Boost::Bind and virtual function overloads: why do they work?
问题 I wrote some code and got scared that it will not work - so I wrote a prototype: #include <boost/function.hpp> #include <boost/bind.hpp> #include <iostream> class base { private: boost::function<void (int)> action; protected: virtual void onDataBaseReady(int i) { std::cout << i << std::endl; } public: void call() { action(10); } base() { action = boost::bind(&base::onDataBaseReady, this, _1); } }; class child : public base { protected: virtual void onDataBaseReady(int i) { std::cout << i+10 <