1
在升壓DOC:爲什麼我們需要在boost中綁定成員函數?
Binding member functions can be done similarly. A bound member function takes in a pointer or reference to an object as the first argument. For instance, given:
struct xyz
{
void foo(int) const;
};
xyz's foo member function can be bound as:
bind(&xyz::foo, obj, arg1) // obj is an xyz object
我們爲什麼需要& XYZ :: foo的,而不僅僅是XYZ :: foo的?
int f(int a, int b)
{
return a + b;
}
std::cout << bind(f, 1, 2)() << std::endl;
以這種方式,我們不使用&。