Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Complex Number Class
//Title of this code //g++ 4.9.2 #include <iostream> using namespace std; class Complex{ double re; double im; public: // Complex(){re=0;im=0;} Complex(double x=0,double y=0){re=x;im=y;} Complex operator+(const Complex&); Complex operator-(const Complex&); Complex operator%(const Complex&){return Complex();} void operator=(const Complex&); double Get_reel(){return re;} double Get_im(){return im;} friend ostream& operator<<(ostream&, const Complex&); friend istream& operator>>(istream&, const Complex&); }; //Complex::Complex(): re=0,im=0{} Complex Complex::operator+(const Complex& sayi){ double re_num,im_num; re_num=re+sayi.re; im_num=im+sayi.im; return Complex(re_num,im_num); } Complex Complex::operator-(const Complex& sayi){ double re_num,im_num; re_num=re-sayi.re; im_num=im-sayi.im; return Complex(re_num,im_num); } void Complex::operator=(const Complex& sayi){ this->re=sayi.re; this->im=sayi.im; } ostream& operator<<(ostream& out, const Complex& C){ out<<C.re<<"+"<<C.im<<"i"<<endl; return out; } istream& operator>>(istream& in, const Complex& C){ //cout<<"Enter number 1: "; in>>C.re; // in.ignore(3); //cout<<"Enter number 2: "; in>>C.im ; // in.ignore(); return in; } int main() { Complex A(5,3),B(1.5,2.7); cout<<A<<endl<<B<<endl; Complex C; C=A+B; //cout<<C; cin>>C; }
run
|
edit
|
history
|
help
0
IndiSort
Eratosfen final
PLoshtina na krug
subset sum=k(dp)
5345
Avoiding visited networked paths
Hello
stl_sizeof.cc
completed
count common elements in three sorted array without using extraspace