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

玉林网站设计做编程的 网站有哪些内容

玉林网站设计,做编程的 网站有哪些内容,东莞短视频推广属于什么,郑州网站建设哪家好怎么样1.理论知识 2.常用函数适配器 标准库提供一组函数适配器#xff0c;用来特殊化或者扩展一元和二元函数对象。常用适配器是#xff1a; 1绑定器#xff08;binder#xff09;: binder通过把二元函数对象的一个实参绑定到一个特殊的值上#xff0c;将其转换成一元函数对象…1.理论知识 2.常用函数适配器 标准库提供一组函数适配器用来特殊化或者扩展一元和二元函数对象。常用适配器是 1绑定器binder: binder通过把二元函数对象的一个实参绑定到一个特殊的值上将其转换成一元函数对象。C标准库提供两种预定义的binder适配器bind1st和bind2nd前者把值绑定到二元函数对象的第一个实参上后者绑定在第二个实参上。 2取反器(negator) : negator是一个将函数对象的值翻转的函数适配器。标准库提供两个预定义的ngeator适配器not1翻转预定义一元函数对象的真值,而not2翻转二元谓词函数的真值。 常用函数适配器列表如下 bind1st(op, value) bind2nd(op, value) not1(op) not2(op) mem_fun_ref(op) mem_fun(op) ptr_fun(op) 3.典型案例 class IsGreat { public:IsGreat(int i){m_num i;}bool operator()(int num){if (num m_num){return true;}return false;} protected: private:int m_num; };void main43() {vectorint v1;for (int i0; i5; i){v1.push_back(i1);}for (vectorint::iterator it v1.begin(); it!v1.end(); it ){cout *it ;}int num1 count(v1.begin(), v1.end(), 3);cout num1: num1 endl;//通过谓词求大于2的个数int num2 count_if(v1.begin(), v1.end(), IsGreat(2)); cout num2: num2 endl;//通过预定义函数对象求大于2的个数 greaterint() 有2个参数 // param 2int num3 count_if(v1.begin(), v1.end(), bind2nd(greaterint(), 2 ) );cout num3: num3 endl;//取模 能被2整除的数 求奇数int num4 count_if(v1.begin(), v1.end(), bind2nd(modulus int(), 2 ) ); cout 奇数num4: num4 endl;int num5 count_if(v1.begin(), v1.end(), not1( bind2nd(modulus int(), 2 ) ) ); cout 偶数num5: num5 endl;return ; } 4.预定义函数对象和适配器案例代码 #include iostream using namespace std;#include string #include vector #include list #include set #include algorithm #include functional//plusint 预定义好的函数对象 能实现不同类型的数据的 运算 //实现了 数据类型 和算法的分离 》通过函数对象技术实现的。。。。//思考怎么样知道 plustype 是两个参数 void main21() {/*templateclass _Tystruct plus: public binary_function_Ty, _Ty, _Ty{ // functor for operator_Ty operator()(const _Ty _Left, const _Ty _Right) const{ // apply operator to operandsreturn (_Left _Right);}};*/plusint intAdd;int x 10; int y 20;int z intAdd(x, y); // x y cout z: z endl;plusstring stringAdd;string s1 aaa;string s2 bbb;string s3 stringAdd(s1, s2);cout s3: s3 endl;vectorstring v1;v1.push_back(bbb);v1.push_back(aaa);v1.push_back(ccc);v1.push_back(zzz);v1.push_back(ccc);v1.push_back(ccc);/*templateclass _Tystruct greater: public binary_function_Ty, _Ty, bool{ // functor for operatorbool operator()(const _Ty _Left, const _Ty _Right) const{ // apply operator to operandsreturn (_Left _Right);}};*/sort(v1.begin(), v1.end(), greaterstring() );for (vectorstring::iterator itv1.begin(); it!v1.end(); it){cout *it endl;}//求 ccc 出现的个数string sc ccc;//equal_tostring() 有两个参数 left参数来自容器right参数来自sc//bind2nd函数适配器 把预定义函数对象 和 第二个参数进行绑定int num count_if(v1.begin(), v1.end(), bind2nd(equal_tostring(), sc) );cout num: num endl; }class IsGreat { public:IsGreat(int i){m_num i;}bool operator()(int num){if (num m_num){return true;}return false;} private:int m_num; };void main22() {vectorint v1;for (int i0; i10; i){v1.push_back(i1);}for (vectorint::iterator itv1.begin(); it!v1.end(); it ){cout *it ;}cout endl;int num1 count(v1.begin(), v1.end(), 3);cout num1: num1 endl;//通过 谓词 求大于2 的个数int num2 count_if(v1.begin(), v1.end(), IsGreat(2));cout num2: num2 endl;/*templateclass _Tystruct greater: public binary_function_Ty, _Ty, bool{ // functor for operatorbool operator()(const _Ty _Left, const _Ty _Right) const{ // apply operator to operandsreturn (_Left _Right);}};*///通过 预定义的函数对象 求大于2 的个数//greaterint() 有两个参数 左参数来自容器的元素 右参数固定成2 通过bind2nd做的int num3 count_if(v1.begin(), v1.end(), bind2nd (greaterint(), 2) );cout num3: num3 endl;//求 奇数的个数int num4 count_if(v1.begin(), v1.end(), bind2nd (modulusint(), 2) );cout 奇数的个数num4: num4 endl;//求 偶数的个数 取反器(negator) int num5 count_if(v1.begin(), v1.end(), not1( bind2nd (modulusint(), 2) ) );cout 偶数的个数 num5: num5 endl;} void main2222() {//main21();main22(); //函数适配器综合案例couthello...endl;system(pause);return ; }
http://www.zqtcl.cn/news/871940/

相关文章:

  • 那个公司做的网站详情页好看做动态图片的网站吗
  • 旅游网站模板文章wordpress 删除
  • 沛县专业做网站wordpress id重置密码
  • 湖南邵阳建设局网站做外贸一般用什么网站
  • html网站开发主要涉及哪些技术越秀金融大厦地址
  • 北京建设银行网站田村广州室内设计公司排行榜
  • 安徽金路建设集团有限公司网站平面设计班培训入门
  • 小型电子商务网站开发php mysql网站开发教程
  • 网站建设常州麦策电商2 网站建设的一般步骤包含哪些
  • cn免费域名注册网站企业推广的渠道有哪些
  • 关于网站建设心得体会网站的功能包括哪些
  • 番禺网站制作技术网站建设与管理pdf
  • 毕业设计做网站选题营销型网站功能模块
  • 西部数码网站管理助手安装建工教育网
  • wordpress 网站logowordpress文本编辑器插件
  • 杭州装饰网站建设如何免费建购物网站
  • 在vs做的项目怎么连接到网站珠海有什么网站
  • 网上购物网站建设论文6做的网站必须放在idc机房吗
  • 基于asp.net的视频网站开发500套wordpress模板
  • 商城模板建站价格寻找专业网站建设
  • 网址我的上网主页seo培训中心
  • 上海建网站服务器河南网站推广优化排名
  • 夸克作文网站淄博团购网站建设
  • 家居类企业响应式网站一个很好的个人网站开发
  • 推荐网站建设服务器百度竞价入口
  • 微信如何做网站100个成功营销策划案例
  • 手机网站分享js代码外贸网站做几种产品
  • 文化网站建设论文wordpress模板打包
  • 学校网站查询做网站 先上线再调整
  • 如何制作一个好网站培训教育网站开发