Why is there an ampersand when taking the address of a member function as opposed to a global function? I.e., why something like
std::bind(&MyClass::MemberFunction, ...);
when global functions would require
std::bind(GlobalFunction, ...);
?
Why is there an ampersand when taking the address of a member function as opposed to a global function? I.e., why something like
std::bind(&MyClass::MemberFunction, ...);
when global functions would require
std::bind(GlobalFunction, ...);
?
C
allowed implicit conversions from global function names to pointers to those functions. C++
kept these implicit conversions for backwards compatibility reasons. C
does not have member functions, and so there was no need to provide the implicit conversion in the case of member functions.
C++
does not allow the implicit conversion in the cases where it was not forced to for compatibility with C
, because it was felt that such conversions were confusing and possibly ambiguous, while providing few benefits.