#include "stdafx.h"
#include<iostream>
#include<conio.h>
using namespace std;
class complex
{
private:
float real;
float imag;
public:
complex(){}
complex(float a, float b)
{
real = a;
imag = b;
}
void display()
{
cout << real<< " +j" <<imag<< "\n";
}
complex operator+(complex);
};
complex complex::operator+(complex c)
{
complex temp;
temp.real= real + c.real;
temp.imag = imag + c.imag;
return(temp);
}
void main()
{
complex c1(3, 5), c2(4, 6), c3;
c3 = c1 + c2;
c1.display();
c2.display();
c3.display();
_getch();
}
0 التعليقات:
إرسال تعليق