<iostream>
using namespace std;
class complex
{
x;
y;
:
input(float real, float img)
{
x=real;
y=img;
}
complex sum(complex, complex);
show(complex);
};
complex sum(complex c1, complex c2)
{
complex c3;
c3.x=c1.x+c2.x;
c3.y=c1.y=c2.y;
(c3);
}
complex:: show(complex c)
{
std::cout<<c.x<<"+j"<<c.y<<"\n";
}
main()
{
complex a,b,c;
a.input(3.1,5.65);
b.input(2.75,1.2);
c=sum(a,b); // c=a+b;
std::cout<<"a=";
a.show(a);
std::cout<<"b=";
b.show(b);
std::cout<<"c=";
c.show(c);
}
|