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

河北廊坊建设银行网站wordpress不能搜索文章

河北廊坊建设银行网站,wordpress不能搜索文章,残疾人无障碍网站建设,直播网站开发好做么友元 意义 程序中#xff0c;有些私有属性也想让类外特殊的一些函数或者类进行访问#xff0c;就要用到友元技术 关键字 friend 友元的三种实现 全局函数做友元 class Room{friend void test(Person p);//friend class test;public:string phone_number;private:string…友元 意义 程序中有些私有属性也想让类外特殊的一些函数或者类进行访问就要用到友元技术 关键字 friend 友元的三种实现 全局函数做友元 class Room{friend void test(Person p);//friend class test;public:string phone_number;private:string bedroom; }void test(Person p){cout p-bedroom endl;}类做友元 friend class test; 成员函数做友元 friend void GoodGay::visit();GoodGay类下的visit成员函数作为本类的好朋友可以访问私有成员 运算符重载 概念 对已有的运算符重新进行定义赋予其另一种功能以适应不同的数据类型主要是重载函数的函数名就是operator这是编译器起好的 加号 成员函数重载调用的本质Person p3 p1.operator(p2); class Person{public:Person operator(Person p){Person temp;temp.m_A this-m_A p.m_A;temp.m_B this-m_B p.m_Areturn temp;}}全局函数重载调用的本质Person p3 operator(p1, p2); Person operator(Person p1, Person p2){Person temp;temp.m_A p1.m_A p2.m_A;temp.m_B p1.m_B p2.m_B;return temp;}函数重载依然适用于符号重载 左移—输出—可以输出自定义数据类型—需要配合友元 成员函数—不可行—因为无法实现对象在右边这种情况 p.operator(cout)简化为p cout 只能利用全局函数重载 operator(cout, p) 简化 cout p ostream operator(ostream cout, Person p){cout m_A p.m_A;return cout;}//cout其实也是一个对象为了满足链式编程故而不可以重新创建后返回因此采用引用问题—如果是私有属性这种全局函数无法访问怎么办—友元函数 递增/递减运算符重载—存在前置递增和后置递增 前置递增和后置递增的区分—采用占位参数前置递增返回的是引用后置递增返回的是数值 因为后置递增返回的是临时对象 class Num{friend ostream operator(ostream cout, Num n);private:int n_Num;public:Num(int a): n_Num(a) {return ;}Num operator(void){n_Num;return *this;}Num operator(int){Num temp (n_Num);n_Num;return temp;} };ostream operator(ostream cout, Num n){cout n.n_Num endl;return cout;}int main(){Num n(1);cout n endl;cout n endl;cout n endl;return 0;}赋值运算符 赋值运算其实也是默认就有的—属性值拷贝编译器提供的赋值运算符的操作是一个浅拷贝的操作因此在涉及到内存问题时候需要进行深拷贝故而需要进行重载 有连续赋值行因此涉及到链式编程 class Age{friend ostream operator(ostream cout, Age n);private:int* m_age;public:Age(int age){m_age new int(age);}Age(const Age age){if(m_age ! NULL){delete m_age;m_age NULL;}m_age new int(*age.m_age);}Age operator(Age p){if(m_age ! NULL){delete m_age;m_age NULL;}m_age new int(*p.m_age);return *this;}~Age(){if(m_age ! NULL){delete m_age;m_age NULL;}}};ostream operator(ostream cout, Age n){cout *n.m_age endl;return cout;}int main(){Age a(10);Age b(20);Age c(30);cout a endl;cout b endl;cout c endl;a b c;cout a endl;return 0;}关系运算符 意义 让两个对象可以进行比较 class Person{public:int m_age;string m_name;Person(string m_name, int m_age){this-m_name m_name;this-m_age m_age;}bool operator(Person p){if(this-m_age p.m_age this-m_name p.m_name){return true;}return false;}bool operator!(Person p){if(this-m_age ! p.m_age || this-m_name p.m_name){return true;}return false;}};函数调用运算 ()也可以重载由于重载后使用的方式非常像函数的调用因此称为访函数访函数没有固定写法非常灵活 class Myprintf{public:void operator()(string test){cout test endl;}}Myprintf printf;printf(hello cpp);匿名函数 类型()Myprintf()(“hello cpp”);
http://www.hkea.cn/news/14336913/

相关文章:

  • wordpress 恢复初始化seo关键词排名注册价格
  • 徐州网站开发要多少钱互联网推广企业
  • 做网站的人中国五大门户网站
  • 医疗网站建设怎么样网站没快照
  • 松江新城建设集团有限公司网站photoshop手机版在线使用
  • 网站重构工程师外综服网站开发
  • 网站降权该怎么做wordpress快速工具
  • ip做网站需要过白名单吗企业建站公司哪里有
  • 网站建设 域名业务 邮箱手机版网页开发者工具
  • 泉州网站域名注册人怎么查询
  • 昆明网站建设公司猎狐科技怎么样wordpress怎么更换网站logo
  • 吉安知名网站建设做内衣的网站
  • 县城房地产网站可以做吗珠海企业官网设计制作
  • 西安网站排名优化中建西部建设西南有限公司网站
  • 上海 网站设计 公司宁波网络设计有限公司有哪些
  • 两学一做专题教育网站wordpress如何
  • 做影视网站风险大吗网站开发外包 合同
  • 做自己网站做站长如何制作一个小程序
  • 自己怎么做一元购物网站做排名的网站
  • 建设官方网站查询文具网站建设合同书
  • 宝塔做网站安全吗视觉设计的网站和app
  • 百度怎么收录网站oa办公系统流程审批
  • 四川seo整站优化吧江苏网站建设价格
  • 网站建设是什么?开通企业网站需要多少钱
  • 高新营销型网站建设公司北京网站建设推广服
  • 站长之家怎么查询网站哪家做的怎么样关键词优化
  • 免费html网站制作成品定制衣柜设计方案
  • 网站选项卡代码门户网站概念
  • 专业做红木家具网站室内设计效果图全景图
  • 天津做网站公司在线教育网站源码