Virtual member-function pointers are called polymorphically - evn through a boost::function object.
You have to have an object instance to call a member function pointer:
So you only need to push_back a &encryptionStrategyFactory::createEncryptor. Then use the factory instance when invoking the pushed-back member-function pointer.Code:#include <boost/function.hpp> #include <iostream> #include <vector> using namespace std; struct A { virtual void foo() {cout << "A::foo" << endl;} };//A struct B : public A { virtual void foo() {cout << "B::foo" << endl;} };//B struct C : public A { virtual void foo() {cout << "C::foo" << endl;} };//C int main() { A a; B b; C c; typedef boost::function<void (A*)> Fn; vector<Fn> vFn; vFn.push_back(&A::foo); vFn[0](&a); vFn[0](&b); vFn[0](&c); return 0; }//main
gg




Reply With Quote