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

专业网站的公司流量对网站的作用

专业网站的公司,流量对网站的作用,广元建设局网站,现在开什么网站以下是一个用运算符重载为友元重载的方法重做复数加减法的运算&#xff0c;请填空完成程序。 #include <iostream> using namespace std; class CComplex { private:double real; double imag; public:CComplex(double r0.0,double i0.0){ real(r), imag(i)}friend…

以下是一个用运算符重载为友元重载的方法重做复数加减法的运算,请填空完成程序。

#include <iostream>
using namespace std;
class CComplex
{    
private:double real; double imag;
public:CComplex(double r=0.0,double i=0.0){ 
real(r), imag(i)}friend CComplex operator + (CComplex c1, CComplex c2);friend CComplex operator - (CComplex c1, CComplex c2);void display();
};
CComplexoperator + (CComplex c1, CComplex c2){return 
CComplex(c1.real + c2.real, c1.imag + c2.imag)
;}
CComplex operator - (CComplex c1, CComplex c2){return 
CComplex(c1.real - c2.real, c1.imag - c2.imag)
;}
void 
CComplex::display(){cout<<"("<<real<<","<<imag<<")"<<endl;}
int main()
{    CComplex c1(5,4),c2(2,10),c3,c4;cout<<"cl=";    c1.display();             cout<<"c2=";    c2.display();c3=c1-c2;        cout<<"c3=c1-c2=";    c3.display();c4=c1+c2;    cout<<"c4=c1+c2=";    c4.display();return 0;
}

数组重载的运算符[ ]
分数 9
作者 谢颂华
单位 武汉理工大学
已知一维数组类ARRAY的定义如下,ARRAY与普通一维数组区别是:其重载的运算符[ ]要对下标是否越界进行检查。

#include <iostream>
#include <string.h>
using namespace std;
class ARRAY{   int *v;       //指向存放数组数据的空间int s;        //数组大小  
public:   ARRAY(int a[], int n){if(n<=0) {v=NULL;s=0;return;}s=n;v= new int[n];for(int i=0; i<n; i++) v[i]=a[i];}~ ARRAY(){delete []v;}int size(){ return s;} int& operator[](int n); 
};
int& ARRAY::
operator[](int n)  //[ ]的运算符成员函数定义
{if(n<0 || 
n >= s
) {cerr<<"下标越界"; }return 
v[n]
;
}int main()
{int x[]={2,4,6,8};ARRAY A(x,4);for(int i=0; i<4; i++)cout<<A[i]<<" ";return 0;
}

Point类运算符+重载为友元
分数 12
作者 谢颂华
单位 武汉理工大学

#include <iostream>
using namespace std;
class Point
{private:int x, y;public:Point(){x=y=0;}Point(int x0,int y0) {x=x0;y=y0;}int GetX() { return x; }int GetY() { return y; }void Print(){cout<<"Point("<<x<<","<<y<<")"<<endl;}friend Point operator+(Point& pt, int dd)
;  //友元函数声明friend Point operator+(Point& pt1, Point& pt2)
;  //友元函数声明
};Point operator+(Point& pt,int dd) //加号操作符重载函数,实现Point类对象与整数加法
{Point temp=pt;temp.x+=dd;temp.y+=dd;return temp
;
}Point operator+(Point& pt1,Point& pt2) //加号操作符重载函数,实现两个Point类对象的加法
{Point temp=pt1;temp.x+=pt2.x;temp.y += pt2.y
;return temp;
}
int main() {Point A(1,4),B(2,3),C;int x=8;C=A+8;C.Print();C=A+B;C.Print();return 0;
}  
http://www.yayakq.cn/news/168699/

相关文章:

  • 上海网站建设公司大全可信网站值得做吗
  • 清远建设网站网站做直播
  • 网站定位 怎么做免费在线观看电影
  • 现代示范校建设专题网站绍兴网络公司
  • 怎么做系统软件网站模板网恋
  • 回收类型网站如何做mvc5 网站开发之美
  • 广告合作手机网站seo教程
  • 怎么做刷会员的网站外贸大楼
  • seo网站推广什么意思wordpress启用静态
  • 安徽省建设厅官方网站各处室免费小程序开发报价
  • 简易企业网站建站及推广
  • 深圳网站建设托管今天的军事新闻
  • 苏州专业网站制作设计上海头条新闻最新消息
  • 官方网站建设的重要性wordpress编辑器媒体库
  • 石岩做网站公司wordpress的网址
  • 报名网站开发多钱网站建设的各个环节
  • 章丘哪里有建设网站的青岛网页设计哪个公司好
  • 做网站绘制蓝图的步骤安卓开发软件
  • 网站建设百度推广总结深圳网站建设哪个平台好
  • 网站服务器租用资质wordpress 文章段落
  • python可以做网站后台吗个人营业执照网上注册入口
  • 深圳电子网站建设一站式网页设计服务平台
  • html5 图片网站网站做优化公司
  • 安徽省高等级公路工程建设指挥部网站什么网站可以做调查
  • 做一个电影网站需要多少钱手机网站页面尺寸
  • 上海企业建站代理注册企业邮箱
  • 哪个公司的网站制作衡阳网站优化方案
  • 建一个设计网站要多少钱网络游戏的利与弊
  • 天津做网站价格西安东郊做网站
  • 超市代理商网站模板微网站定制开发