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

10.03

代码

#include <iostream>using namespace std;
class cz
{
private:int num1;   //实部int num2;   //虚部
public:cz(){}cz(int a,int b):num1(a),num2(b){}cz(const cz &other):num1(other.num1),num2(other.num2){}~cz(){}const cz operator+(const cz &other)const{cz a;a.num1=this->num1+other.num1;a.num2=this->num2+other.num2;return a;}bool operator==(const cz &other)const{if(this->num1==other.num1&&this->num2==other.num2){return true;}else{return false;}}cz & operator+=(const cz &other){this->num1+=other.num1;this->num2+=other.num2;return *this;}cz & operator ++(){this->num1++;return *this;}const cz operator-(const cz &other)const{cz a;a.num1=this->num1-other.num1;a.num2=this->num2-other.num2;return a;}void show(){if(num2<0){cout<<this->num1<<this->num2<<"j"<<endl;}else{cout<<num1<<"+"<<num2<<"j"<<endl;}}
};
int main()
{cz a1(1,-1);a1.show();cz a2(1,2);a2.show();a1+=a2;a1.show();a1=a1+a2;a1.show();a1=a1-a2;a1.show();++a1;a1.show();return 0;
}

效果图

http://www.lryc.cn/news/181268.html

相关文章:

  • 链表单向链表跳跃链表
  • 博客无限滚动加载(html、css、js)实现
  • 腾讯云南京服务器性能如何?南京服务器测速IP地址
  • MySQL和Oracle中,语法的不同点以及如何在xml中书写日期比较大小
  • 谈谈Redis分布式锁
  • Redis的java客户端-RedisTemplate光速入门
  • 格点数据可视化(美国站点的日降雨数据)
  • YoloV8改进策略:LSKNet加入到YoloV8中,打造更适合小目标的YoloV8
  • 力扣-303.区域和检索-数组不可变
  • web:[极客大挑战 2019]LoveSQL
  • 数据结构—快速排序(续)
  • Snapdragon Profiler分析Android GPU
  • Cannot download sources:IDEA源码无法下载
  • 从零开始学习 Java:简单易懂的入门指南之IO字符流(三十一)
  • 监狱工具管理系统-监狱劳动工具管理系统
  • 蓄水池算法
  • 作业 day4
  • erlang练习题(四)
  • YoloV5实时推理最短的代码
  • Tensorflow、Pytorch和Ray(张量,计算图)
  • TinyWebServer学习笔记-让程序跑起来
  • _tkinter.TclError: no display name and no $DISPLAY environment variable 解决
  • 我出手了!
  • springboot的配置文件(properties和yml/yaml)
  • SLAM面试笔记(7) — Linux面试题
  • QUIC不是TCP的替代品
  • 计算机竞赛 目标检测-行人车辆检测流量计数
  • GPT系列模型解读:GPT-1
  • 王杰国庆作业day3
  • 量子计算基础知识—Part1