当前位置: 首页 > news >正文

提升自己网站百度推广外包

提升自己网站,百度推广外包,做外贸可以在哪些网站注册,wordpress 列表 分类A 函数对象 概念&#xff1a; ​ 重载函数调用运算符的类实例化的对象&#xff0c;就叫函数对象.又名仿函数,函数对象和&#xff08;)触发重载函数调用运算符的执行。 作用&#xff1a; ​ 为算法提供策略 示例&#xff1a; #include <iostream> using namespace s…

A 函数对象

概念:

​ 重载函数调用运算符的类实例化的对象,就叫函数对象.又名仿函数,函数对象和()触发重载函数调用运算符的执行。

作用:

​ 为算法提供策略

示例:

#include <iostream>
using namespace std;
class MyClass
{
public:void operator()(int x, int y) {}
};
int main(int argc, char const *argv[])
{//函数对象(仿函数)MyClass c;return 0;
}

B 谓词

概念:

​ 只要 返回值为bool类型的普通函数 或 仿函数 都叫谓词

  • 有一个参数 叫一元谓词
  • 有两个参数 叫二元谓词。
#include <iostream>
using namespace std;
//谓词 
bool method01() {}
// 谓词
class MyClass
{bool operator()() { }
};
//是谓词 更是一元谓词
bool method02(int x) {}
//  二元谓词
bool method03(int x, int y) {}
int main(int argc, char const *argv[])
{return 0;
}

C 内建函数对象

概念 : c++提供的函数对象

1 算法类函数对象

template<classT> T plus<T>//加法仿函数
template<classT> T minus<T>//减法仿函数
template<classT> T multiplies<T>//乘法仿函数
template<classT> T divides<T>//除法仿函数
template<classT> T modulus<T>//取模(取余)仿函数
template<classT> T negate<T>//取反仿函数

注意:6个算数类函数对象,除了negate是一元运算,其他都是二元运算

#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{// template<classT> T plus<T>//加法仿函数cout << "加法仿函数" << endl;plus<int> p1;int x = p1(21, 4);cout << "x = " << x << endl;// template<classT> T negate<T>//取反仿函数cout << "取反函数不能对bool取反" << endl;negate<int> n1;int z = n1(99);cout << "z = " << z << endl;return 0;
}

在这里插入图片描述

2 关系运算类函数对象

语法:

template<class T> bool equal_to<T>//等于
template<class T> bool not_equal_to<T>//不等于
template<class T> bool greater<T>//大于
template<class T> bool greater_equal<T>//大于等于
template<class T> bool less<T>//小于
template<class T> bool less_equal<T>//小于等于

注意:6个关系运算类函数对象,每一种都是二元谓词

逻辑运算类运算函数

template<class T>bool1ogical_and<T>//逻辑与
template<class T>bool1ogical_or<T>//逻辑或
template<class T>bool1ogical_not<T>//逻辑非

注意:3个逻辑运算类运算函数,not为一元谓词,其余为二元谓词。

D 适配器

1 函数对象适配器

用的函数名: for_each ( )

特点:

  • 函数对象作为适配器

使用:

  • bind2nd 将绑定的数据放置第二个参数位置
  • bind1st 将绑定的数据放置第一个参数位置

步骤:

  • 1,创建一个类
  • 2,使该类继承与binary_function
  • 3,泛型萃取
    • 第一泛型为重载的() 运算符中第一个形参的数据类型
    • 第二泛型为重载的() 运算符中第二个形参的数据类型
    • 第三泛型为重载的()运算符中返回值的数据类型
  • 4,在该类中重载() 运算符 记得尾部加 const

在这里插入图片描述

  • 5,创建该类对象
  • 6,使用算法,在算法适配器中使用bind1st或bind2nd绑定该类对象与传入的值

示例:

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
// 1,创建一个类 
// 2,使该类继承与binary_function
// 3,泛型萃取
class MyClass : public binary_function<int, int, void>
{public:在该类中重载() 运算符 记得尾部加  constvoid operator()(int x, int y) const{cout << "x = " << x << endl;cout << "y = " << y << endl;}
};
int main(int argc, char const *argv[])
{vector<int> ns;ns.push_back(1);ns.push_back(2);ns.push_back(3);ns.push_back(4);// 第一种遍历方式 auto 自适应去找我的类型  原生的复杂// for (auto it = ns.begin(); it != ns.end(); it++)// {//     cout << *it << endl;// }// 5,创建该类对象MyClass c;
//使用算法,在算法适配器中使用bind1st或bind2nd绑定该类对象与传入的值 必须继承algorithmfor_each(ns.begin(), ns.end(), bind1st(c, 10));return 0;
}

在这里插入图片描述

2 函数指针适配器

特点:

以全局函数 作为适配器 prt_fun(函数名)

使用:

  • bind2nd 将绑定的数据放置第二个参数位置
  • bind1st 将绑定的数据放置第一个参数位置
  • ptr_fun(函数名)

步骤:

  • 1,定义一个全局函数,该函数两个参数
  • 2,使用算法,在算法适配器中使用bind1st或bind2nd绑定该函数与传入的值

示例:

#include <iostream>
#include <set>
#include <algorithm>  //for_each 头文件
using namespace std;void my_test(int x, int y)
{cout << "x = " << x << endl;cout << "y = " << y << endl;
}
int main(int argc, char const *argv[])
{set<int> ns;ns.insert(1);ns.insert(2);ns.insert(3);ns.insert(4);//遍历for_each(ns.begin(), ns.end(), bind2nd(ptr_fun(my_test),99));return 0;
}

在这里插入图片描述

3 成员函数适配器

特点:

将成员函数(地址)作为适配器

使用:

  • bind2nd 将绑定的数据放置第二个参数位置
  • bind1st 将绑定的数据放置第一个参数位置
  • mem_fun_ref(&类名 :: 函数名)

注意

​ mem_fun_ref(&类名::函数名) 包裹的参数只能有一个 所以也就没有绑定

步骤:

  • 1,创建一个类
  • 2,在该类中编写成员函数
  • 3,使用算法,在算法适配器中使用mem_fun_ref包括该函做

注意:

  • 集合中存储的对象所在的类与成员函数所在的类为同一个类
  • 该函数必须是无参的
  • 集合中的获取的数据

示例:

#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
class MyClass
{
public:int x;MyClass(int x) : x(x) {}void my_show(){cout << "x = " << this->x << endl;}
};
int main(int argc, char const *argv[])
{list<MyClass> ls;ls.push_back(MyClass(1));ls.push_back(MyClass(2));ls.push_back(MyClass(3));ls.push_back(MyClass(4));// 遍历for_each(ls.begin(), ls.end(),mem_fun_ref(&MyClass::my_show));return 0;
}

在这里插入图片描述

4 取反适配器

  • notl 一元函数对象取反
  • not2 二元函数对象取反

示例:

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void show(int x)
{cout << x << ",";
}
bool dy5(int x, int y)
{return x > y;
}
class MyClass : public binary_function<int, int, bool>
{
public:bool operator()(int x, int y) const{return x > y;}
};
int main(int argc, char const *argv[])
{vector<int> nums;nums.push_back(2);nums.push_back(1);nums.push_back(3);nums.push_back(6);nums.push_back(9);for_each(nums.begin(), nums.end(), ptr_fun(show));cout << endl;// 查找vector中第一个大于5的值//  vector<int>::iterator it =find_if(nums.begin(), nums.end(), bind2nd(ptr_fun(dy5), 5));// auto it =find_if(nums.begin(), nums.end(), bind2nd(MyClass(), 5));auto it = find_if(nums.begin(), nums.end(), not1(bind2nd(MyClass(), 5)));cout << *it << endl;// 排序算法sort(nums.begin(), nums.end(), not2(less<int>()));for_each(nums.begin(), nums.end(), ptr_fun(show));cout << endl;return 0;
}

文章转载自:
http://amassment.c7496.cn
http://quicken.c7496.cn
http://gyneocracy.c7496.cn
http://rosenthal.c7496.cn
http://chevalet.c7496.cn
http://professionalism.c7496.cn
http://tetraiodothyronine.c7496.cn
http://cerastium.c7496.cn
http://timbered.c7496.cn
http://electroacupuncture.c7496.cn
http://pregalactic.c7496.cn
http://goboon.c7496.cn
http://cupferron.c7496.cn
http://lowborn.c7496.cn
http://paries.c7496.cn
http://pulverizer.c7496.cn
http://ricketic.c7496.cn
http://triboelectricity.c7496.cn
http://fireless.c7496.cn
http://centrosphere.c7496.cn
http://foxhunter.c7496.cn
http://mealworm.c7496.cn
http://illawarra.c7496.cn
http://serac.c7496.cn
http://enwind.c7496.cn
http://geogeny.c7496.cn
http://evening.c7496.cn
http://newman.c7496.cn
http://hydrophily.c7496.cn
http://untried.c7496.cn
http://brent.c7496.cn
http://erse.c7496.cn
http://crisper.c7496.cn
http://unamo.c7496.cn
http://federally.c7496.cn
http://heller.c7496.cn
http://notarise.c7496.cn
http://scorch.c7496.cn
http://appalling.c7496.cn
http://resinate.c7496.cn
http://syncromesh.c7496.cn
http://postmen.c7496.cn
http://headward.c7496.cn
http://disconnection.c7496.cn
http://salimeter.c7496.cn
http://nitron.c7496.cn
http://demimonde.c7496.cn
http://siangtan.c7496.cn
http://oxyphilic.c7496.cn
http://settled.c7496.cn
http://diddicoy.c7496.cn
http://ownership.c7496.cn
http://overspeed.c7496.cn
http://cerdar.c7496.cn
http://miami.c7496.cn
http://hallway.c7496.cn
http://sensurround.c7496.cn
http://submetacentric.c7496.cn
http://bioactive.c7496.cn
http://zincky.c7496.cn
http://titubation.c7496.cn
http://retrofire.c7496.cn
http://lungy.c7496.cn
http://kola.c7496.cn
http://mf.c7496.cn
http://cancerian.c7496.cn
http://moppie.c7496.cn
http://shamois.c7496.cn
http://unguis.c7496.cn
http://wicketkeeper.c7496.cn
http://slick.c7496.cn
http://surpassingly.c7496.cn
http://beaky.c7496.cn
http://zanu.c7496.cn
http://monopoly.c7496.cn
http://isobutane.c7496.cn
http://chip.c7496.cn
http://halfling.c7496.cn
http://lure.c7496.cn
http://parity.c7496.cn
http://chillness.c7496.cn
http://handcuffs.c7496.cn
http://protochordate.c7496.cn
http://karyoplasm.c7496.cn
http://boniface.c7496.cn
http://noveletish.c7496.cn
http://protrusile.c7496.cn
http://iatrogenicity.c7496.cn
http://paten.c7496.cn
http://ruderal.c7496.cn
http://offendedly.c7496.cn
http://ocelli.c7496.cn
http://rideau.c7496.cn
http://repoussage.c7496.cn
http://ayd.c7496.cn
http://autography.c7496.cn
http://tautochrone.c7496.cn
http://nomadise.c7496.cn
http://troilite.c7496.cn
http://dermestid.c7496.cn
http://www.zhongyajixie.com/news/98972.html

相关文章:

  • mac xampp安装wordpress优化网站关键词排名软件
  • 河北手机网站制作公司sem是什么?
  • wordpress美化下载页面seo推广方案怎么做
  • 简述网站栏目管理seo是什么公司
  • 做暧暧暖网站日本可以投放广告的网站
  • 阿里巴巴有单独网站建设吗成品网站货源1688在线
  • 昆明网站制作在线网站申请流程
  • 长沙旅游攻略三天自由行攻略seo资源咨询
  • 外贸网站建设 惠州注册一个域名需要多少钱
  • wordpress大学主aso搜索优化
  • 网站排名费用网络竞价
  • 国外免费网站百度搜索推广流程
  • 建设局操作证查询优化手机性能的软件
  • 发果怎么做视频网站自己怎么做网址开网站
  • 网站受攻击seo教程技术整站优化
  • 可以用 我爱乳房做网站名不个人seo外包
  • 国内优秀的网站如何制作自己的链接
  • 给网站整一个客服 怎么做互联网营销工具有哪些
  • 网站建设中 请稍后访问北京官方seo搜索引擎优化推荐
  • 杭州移动网站建设搜狗站长工具平台
  • 关于网站开发的文献新闻稿营销
  • 杭州网站建设派迪网络营销培训课程ppt
  • 英文网站建设方案网络公司网页设计
  • 设计网站定制公司网络营销做的比较好的企业
  • 做网站首次备案需要哪些资料友情链接怎么购买
  • 分分彩做号网站东莞做网站哪个公司好
  • word可以制作网页seo网站推广优化就找微源优化
  • 武汉网站整合营销联系方式推广公司是做什么的
  • wordpress整合问答系统上海网络优化服务
  • 网站建设活动策划成都seo专家