What you are looking for is a method pointer associated with an existing object, what is it?
You should look for boost :: bind . If your environment supports it, you can also use std::tr1::bind or even std::bind if it supports C ++ 11.
An example illustrating what you want:
struct X { bool f(int a); }; X x; shared_ptr<X> p(new X); int i = 5; bind(&X::f, ref(x), _1)(i);
The last two examples are interesting in that they create "autonomous" functional objects. bind (& X :: f, x, _1) stores a copy of x. bind (& X :: f, p, _1) stores a copy of p, and since p is boost :: shared_ptr, the function object maintains a reference to its X instance and remains valid even when p exits or reset ().
For the differences between boost::bind , std::tr1::bind and std::bind , I let you see this other SO question.
source share