mobile wallpaper 1
mobile wallpaper 2
mobile wallpaper 3
mobile wallpaper 4
211 words
1 minute
函数对象 - CPP Classes and Objects:Encapsulation
2026-10-19

函数对象概念#

概念#

  • 重载函数调用操作符的类,其对象常称为函数对象
  • 函数对象使用重载的()时,行为类似函数调用,也叫仿函数

本质#

函数对象(仿函数)的一个类,不是一个函数

函数对象使用#

特点#

  • 函数对象在使用时,可以像普通函数那样调用,可以有参数,可以有返回值
  • 函数对象超出普通函数的概念,函数对象可以有自己的状态
  • 函数对象可以作为参数传递

谓词#

概念#

  • 返回bool类型的仿函数称为谓词
  • 如果operator()接受一个参数,那么叫做一元谓词
  • 如果operator()接受两个参数,那么叫做二元谓词

Video#

Share

If this article helped you, please share it with others!

函数对象 - CPP Classes and Objects:Encapsulation
https://www.bilibili.com/video/BV1et411b73Z/?p=237
Author
Memki
Published at
2026-10-19
License
CC BY-NC-SA 4.0

Some information may be outdated

Table of Contents