home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 March
/
Chip_2002-03_cd1.bin
/
chplus
/
cecko
/
CPP
/
COMPLEX.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1998-10-05
|
944b
|
47 lines
// P⌐íklad: Programování v C++ na FJFI - ÇVUT
#ifndef __complex_cpp
#define __complex_cpp
#include <iostream.h>
#include "zlomky.h"
#include "complex.h"
complex complex::operator +(complex c) {
return complex(re+c.re,im+c.im);
}
complex complex::operator -(complex c) {
return complex(re-c.re,im-c.im);
}
complex complex::operator *(complex c) {
complex p;
p.re=re*c.re-im*c.im;
p.im=re*c.im+im*c.re;
return p;
}
complex complex::operator /(complex c) {
complex p;
zlomky pom;
pom=c.re*c.re+c.im*c.im;
p.re=(re*c.re+im*c.im)/pom;
p.im=(im*c.re-re*c.im)/pom;
return p;
}
ostream& operator << (ostream& proud, complex objekt) {
proud << "Re: " << objekt.re;
proud << " Im: " << objekt.im;
return proud;
}
istream& operator >> (istream& proud, complex& objekt) {
cout << "Zadejte re: ";
proud >> objekt.re;
cout << "Zadejte im: ";
proud >> objekt.im;
return proud;
}
#endif