#include "stdafx.h"
#include <iostream>
#include<conio.h>
using namespace std;
class complex
{
private:
int real;
int imag;
public:
void get(int h, int m)
{
real = h;
imag = m;
}
void putdata()
{
cout<< real << "+ j " << imag <<"\n";
}
friend complex sum(complex, complex);
};
complex sum(complex c1, complex c2)
{
complex c3;
c3.real = c1.real + c2.real;
c3.imag = c1.imag + c2.imag;
return (c3);
}
void main()
{
complex a, b, c;
a.get(22, 45);
b.get(33, 55);
c = sum(a, b);
cout << "complex 1 : ";
a.putdata();
cout << "complex 2 : ";
b.putdata();
cout << "complex 3 : ";
c.putdata();
_getch();
}
0 التعليقات:
إرسال تعليق