4-3
来源:互联网 发布:淘宝卖家中心下载安装 编辑:程序博客网 时间:2024/06/03 01:35
#include <iostream.h>class Complex{public:Complex(){ real=0; imag=0;}Complex(double r,double i){ real=r; imag=i;} Complex operator +(Complex &);Complex operator +(int &);friend Complex operator +(int &,Complex &);void display(){ cout<<"("<<real<<"+"<<imag<<"i)"<<endl;}private:double real;double imag;};Complex Complex::operator +(Complex &c2){ return Complex(real+c2.real,imag+c2.imag);}Complex Complex::operator +(int &i){ return Complex(real+i,imag);}Complex operator +(int &i,Complex &c3){ return Complex(i+c3.real,c3.imag);}int main(){ int i=2; Complex c1(2,4),c2(1,2),c3,c4,c5; c3=c1+c2; cout<<"c3=c1+c2="; c3.display(); c4=c1+i; cout<<"c4=c1+i="; c4.display(); c5=i+c2; cout<<"c5=i+c2="; c5.display(); return 0;}
0 0
- 3 - 4
- 3-4
- 4-3
- 3-4
- 4-3
- 3-4
- 3-4
- 4-3
- 3+4
- 《c语言程序设计》例题 4-3 4-4
- 3/4-3/6 js
- 3-4 小记
- 2-3-4Tree
- 4/3系统数码单反
- 3/4/2008
- 1+4=3
- 4-3上街
- CCNA 3 Chapter 4
- Java牛人博客
- 4-2
- 第11周-项目2-摩托车继承自行车和机动车
- POJ1836【Romania OI 2002】Alignment
- php zend api【第一次】
- 4-3
- java之定时器
- 第十一周 项目四--类族的设计(3)
- Java 程序员必须知道的10个调试技巧
- 《鸟哥的Linux私房菜》读书笔记:软件安装——源代码与Tarball
- java-事件处理机制
- ios的hitTest方法以及不规则区域内触摸事件处理方法
- 第11周-项目3-日期时间类
- iOS 键盘显示或消失的监听,获取键盘高度