[bind,function,mem_fn] Connection to a base class
Hi, I have the following problem and don't know how to design it with the boost tools at hand: I have a base class X with two functions f and g class X { virtual bool f() const; virtual bool g(int) const; }; and another class Y with functions f1, f2 and F class Y { void f1(); void f2(); void F(???); }; Now, f1 and f2 should call F, but f1 should determine that F calls X::f polymorphically and f2 should determine that F calls X::g polymorphically. Y::f1() { // call F so that F works on X::f F(??? X::f); } Y::f2() { // call F so that F works on Y::g but with g's int parameter known and determined in Y::f2 int v = 5; F(??? X::g, v); } Y::F(???) { smart_ptr<Y> sp1(new Y); smart_ptr<Y> sp2(new Y); // Either call Y::f on sp1 and sp2, or call Y::g(5) on sp1 and sp2 } Is this possible? I have looked into the documentation of boost::bind, boost::mem_fn and boost::function but didn't find a way to do that. Could someone give me some hint? With best regards Johannes Brunen
participants (1)
-
Johannes Brunen