Why would one use function pointers to member method in C++?

前端 未结 10 2168
情书的邮戳
情书的邮戳 2021-02-10 23:48

A lot of C++ books and tutorials explain how to do this, but I haven\'t seen one that gives a convincing reason to choose to do this.

I understand very well why functio

10条回答
  •  天涯浪人
    2021-02-11 00:37

    It is like using lambdas. You always can pass all necessary local variables to a simple function, but sometimes you have to pass more then one of them.

    So using member functions will save you from passing all necessary member fields to a functor. That's all.

提交回复
热议问题