#include<iostream.h>
class complex
{
private: double real,imag;
public: complex(){}
complex(double r,double i)
{
real=r;
imag=i;
}
friend ostream& operator<<(ostream &s,complex &c);
friend istream& operator>>(istream &s,complex &c);
};
ostream& operator<<(ostream &s,complex &c)
{
s<<"("<<c.real<<","<<c.imag<<")";
return s;
}
istream& operator >> (istream &s,complex &c)
{
s>>c.real>>c.imag;
return s;
}
void main()
{
complex c1(1.5,2.5),c2(3.5,4.5),c3;
cout<<endl<<"c1="<<c1<<"\nc2="<<c2;
cout<<endl<<"\n Enter a complex number=";
cin>>c3;
cout<<"c3="<<c3;
}
class complex
{
private: double real,imag;
public: complex(){}
complex(double r,double i)
{
real=r;
imag=i;
}
friend ostream& operator<<(ostream &s,complex &c);
friend istream& operator>>(istream &s,complex &c);
};
ostream& operator<<(ostream &s,complex &c)
{
s<<"("<<c.real<<","<<c.imag<<")";
return s;
}
istream& operator >> (istream &s,complex &c)
{
s>>c.real>>c.imag;
return s;
}
void main()
{
complex c1(1.5,2.5),c2(3.5,4.5),c3;
cout<<endl<<"c1="<<c1<<"\nc2="<<c2;
cout<<endl<<"\n Enter a complex number=";
cin>>c3;
cout<<"c3="<<c3;
}
No comments:
Post a Comment