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

10.2总结

#include <iostream>using namespace std;class MyString
{
private:string pos1;string pos2;
public:MyString(){}MyString(string pos1,string pos2):pos1(pos1),pos2(pos2){cout << "调用了有参构造" << endl;}MyString(const MyString &other):pos1(other.pos1),pos2(other.pos2){cout << "调用了拷贝构造函数" << endl;}const MyString operator+(const MyString &R)const{MyString t;t.pos1 = pos1+R.pos1;t.pos2 = pos2+R.pos2;return  t;}const MyString operator>(const MyString &R)const{MyString t;t.pos1 = (pos1>R.pos1)?"true":"false";t.pos2 = (pos2>R.pos2)?"true":"false";return  t;}const MyString operator<(const MyString &R)const{MyString t;t.pos1 = (pos1<R.pos1)?"true":"false";t.pos2 = (pos2<R.pos2)?"true":"false";return  t;}const MyString operator==(const MyString &R)const{MyString t;t.pos1 = (pos1==R.pos1)?"true":"false";t.pos2 = (pos2==R.pos2)?"true":"false";return  t;}void input(){cout << "请输入pos1: ";cin >> pos1;cout << "请输入pos2: ";cin >> pos2;}void output() const{cout << "pos1: " << pos1 << ", pos2: " << pos2;}void show(){cout << "pos1的长度为" << pos1.size() << endl;cout << "pos2的长度为" << pos2.size() << endl;cout << "pos1= " << pos1 << " " << "pos2= " << pos2 << endl;}};int main()
{//    MyString s1("z","x");//    MyString s2("b","a");MyString s1;s1.input();// s1.output();MyString s2;s2.input();//s2.output();MyString s =s1+s2;MyString s3 =s1>s2;s.show();s3.show();return 0;
}

http://www.dtcms.com/a/435235.html

相关文章:

  • 旅游网站建设最重要的流程如何制作公众号教程
  • 淄博建设局网站秀堂h5官网
  • 【动态规划DP:纸币硬币专题】P2834 纸币问题 3
  • springbatch使用记录
  • 平面设计师网站都有哪些网站突然被降权怎么办
  • 前向传播与反向传播(附视频链接)
  • 广州建设工程造价管理站橙色网站欣赏
  • ipv6之6to4配置案例
  • 太仓有专门做网站的地方吗沧州企业网站专业定制
  • gRPC从0到1系列【14】
  • JVM的内存分配策略有哪些?
  • 卡特兰数【模板】(四个公式模板)
  • Process Monitor 学习笔记(5.5):保存/打开追踪记录——复盘、复现与分享的正确姿势
  • 【机器学习宝藏】深入解析经典人脸识别数据集:Olivetti Faces
  • 【C++】深入理解红黑树:概念、性质和实现
  • 制作卖东西网站玩具网站 下载
  • 网站建设培训课程wordpress描述插件
  • php网站超市源码下载十大永久免费crm
  • 网站色彩代码carousel wordpress
  • 帮别人做网站一般app开发费用多少
  • 上海网站建设服务市价编程做网站容易还是做软件
  • Go 语言流程控制详解:if / switch / for
  • 企业网站栏目设计h5手机网站实例
  • 操作系统应用开发(十三)RustDesk文件服务搭建——东方仙盟筑基期
  • 莱州网站建设服务程序开发的步骤是什么
  • 网站域名多少钱一年杭州seo公司排名
  • 武昌网站制作公司深圳vi设计公司推荐
  • AI驱动的软件质量保障:未来已来
  • Lama Cleaner图片去水印工具最新版IOPaint-1.5.3使用教程-优雅草卓伊凡
  • Spring Boot 配置属性绑定