그래서 필요 (이러한 상황에서 현재 클래스에 대한 링크 일 것입니다 무슨) : 우리는 클래스에 가입 A
내부에 있다면 내가 이해하면C++는이
struct A { void foo(int) { } };
typedef std::function<void(int)> Function;
typedef std::vector<Function> FunctionSequence;
typedef FunctionSequence::iterator FunctionIterator;
FunctionSequence funcs;
A a;
funcs.push_back(std::bind(&A::foo, &a, std::placeholders::_1));
funcs.push_back(std::bind(&B::bar, &b, std::placeholders::_1));
// this calls a.foo(42) then b.bar(42):
for (FunctionIterator it(funcs.begin()); it != funcs.end(); ++it)
(*it)(42);
는 funcs.push_back
우리는 대신 &a
this
C++ 0x 인 경우 람다 식을 사용하십시오. – Puppy