1 - #include<iostream.h>/using namespace std class...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #include <iostream.h> //using namespace std; class complex { friend istream &operator>>(istream & in,complex &c);//ÓÑÔªÉùÃ÷ friend void output(complex c);//ÓÑÔªÉùÃ÷ friend complex operator-(const complex &c1,const complex &c2); friend ostream & operator<< (ostream & out,const complex &c ); friend complex operator-(complex c); public: complex(){} complex(double r,double i=0) { this->real=r; t image=i; } complex(complex &c) { this->real=c.real; this->image=c.image; } void print(); v complex operator+(complex c2) { complex c; c.real =this->real+c2.real ; c.image =this->image+c2.image ; return c; // return complex(this->real+c2.real ,this->image+c2.image); } /* complex operator-()//³ÉÔ±º¯Êý { return complex(-real,-image); }*/ complex operator+=(complex c2) { real=real+c2.real ; image=image+c2.image ; return *this; } bool operator==(complex c2) { if(real==c2.real &&image==c2.image )return true; return false; } bool operator!=(complex c2) { if(real!=c2.real ||image!=c2.image )return true;if(real!...
View Full Document

This note was uploaded on 10/04/2011 for the course CS 142 taught by Professor Staff during the Spring '08 term at BYU.

Page1 / 3

1 - #include<iostream.h>/using namespace std class...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online