What are C++ functors and their uses?

后端 未结 14 1445
花落未央
花落未央 2020-11-21 04:27

I keep hearing a lot about functors in C++. Can someone give me an overview as to what they are and in what cases they would be useful?

14条回答
  •  执笔经年
    2020-11-21 04:46

    Functor can also be used to simulate defining a local function within a function. Refer to the question and another.

    But a local functor can not access outside auto variables. The lambda (C++11) function is a better solution.

提交回复
热议问题