内建函数对象意义
概念:
- STL内建了一些函数对象
分类:
-
算术仿函数
-
关系仿函数
-
逻辑仿函数
用法:
- 这些仿函数所产生的对象,用法和一般函数完全相同
- 使用内建函数对象,需要引入头文件
#include<functional>
#include <iostream>
#include <functional>
using namespace std;
//negate
void test01()
{
negate<int> n;
cout << n(50) << endl;
}
//plus
void test02()
{
plus<int> p;
cout << p(10, 20) << endl;
}
int main()
{
test01();
test02();
return 0;
}
//总结: 使用内建函数对象时,需要引入头文件#include <functional>