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

网站名称没有排名软件工程流程

网站名称没有排名,软件工程流程,文员工作内容,室内效果图网站关于C操作符重载&#xff0c;可以用类内的成员运算符重载或友元函数。但是注意两个不能同时出现&#xff0c;不然编译出错。 #include<iostream> using namespace std; class Complex{public:Complex(int r0,int i0){real r;imag i;}//#if 0Complex operator(Complex …

关于C++操作符重载,可以用类内的成员运算符重载或友元函数。但是注意两个不能同时出现,不然编译出错。

#include<iostream>
using namespace std;
class Complex{public:Complex(int r=0,int i=0){real = r;imag = i;}//#if 0Complex operator+(Complex &c) {cout << " internal function is called" << endl;Complex c2;c2.real = this->real + c.real;c2.imag = this->imag + c.imag;return c2;}
//    #endif void print();friend Complex operator+(int a,Complex &c2); //声明友元运算符重载函数,+的左侧是整数,右侧是类的对象 friend Complex operator+(Complex c1,int a);//声明友元运算符重载函数,+的右侧是整数,左侧是类的对象
//     friend Complex operator+(Complex c1,Complex c2);//声明友元运算符重载函数,+的右侧是整数,左侧是类的对象 private:int real;int imag;
};
Complex operator+(int a,Complex &c2)  //定义友元运算符重载函数,+的左侧是整数,右侧是类的对象 
{Complex temp;cout << "friend function 1 is called" << endl;temp.real = a+c2.real;temp.imag = c2.imag;return temp;
}
Complex operator+(Complex c1,int a)//定义友元运算符重载函数,+的右侧是整数,左侧是类的对象 
{Complex temp;cout << "friend function 2 is called" << endl;temp.real = c1.real+a;temp.imag = c1.imag;return temp;
} 
#if 0
Complex operator+(Complex c1,Complex c2)
{Complex temp;cout << "friend function 3 is called" << endl;temp.real = c1.real+c2.real;temp.imag = c1.imag+c2.imag;return temp;
}
#endifvoid Complex::print()
{cout<<real<<"+"<<imag<<'i'<<endl;
}int main()
{Complex co1(30,40),co2(30,40),co3,co4;co1.print();co3=100+co1;  //co3=operator+(100,co1); co3.print();co3=co2+100;  //co3=operator+(co2,100);co3.print();co4=co2+co3;co4.print();return 0;
}
http://www.yayakq.cn/news/445523/

相关文章:

  • 科学家做实验的网站商城网站开发网络公司
  • 广告设计案例网站毕业设计怎么做网站
  • 江阴市建设局官网站公司建设网站费用会计分录
  • 摄影欣赏网站哪个最好seo推广服务
  • 怎么查找网站的服务器3合1网站建设公司
  • 设计网站公司 讲湖南岚鸿本地南京网站建设
  • 企业如何做网站推广html5网页设计作业免费
  • 广告传媒公司网站怎么做做贺卡的网站
  • 橙色网站logo 配色陕西建设网网
  • 系部网站建设中期检查表网站换主题
  • 河南建设银行招聘网站家教网站建设模板
  • 啥是东莞网站优化推广腾讯云服务器租用价格表
  • 第三方商城网站建设南通网站建设
  • 网站建设找谁net域名网站
  • 营销型网站的评价长沙做暑假实践活动网站
  • 深圳福田网站建设专业公司网站推广公司排名点击查看
  • 如何建立一个论坛网站戚墅堰网站建设
  • 甘肃省 网站建设 审批个人 可以做社交网站
  • 商务网站建设推荐企业网站建设成本
  • 多种不同产品的网站怎么做seo做网站开发需要学哪些东西
  • 网站做301将重定向到新域名互联网金融
  • 网站建设课程设计实训报告手机上网站用建设工具
  • 一款非常不错的seo网站优化公司源码蓝色门户网站
  • 学做网站的书籍公司网页设计报告5000字
  • 楚雄市住房和城乡建设局门户网站学服装设计后悔死了
  • 怎么给网站做动图申晨推荐的营销网站
  • 建立网站站点的过程莞城网站制作
  • 学了lamp做网站就足够了吗新网站的建设方案
  • 北京龙鼎网站建设公司网站代码怎么放
  • 电子商务网站模式定做微信小程序