Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (28.79 KB, 2 trang )
#include<stdio.h>
#include<conio.h>
class Complex
{
public:
Complex (int th=0,int a=0) //constructor
{
thuc=th;
ao=a;
}
void Print() //ham xuat so phuc
{
if(thuc==0)
{
printf("%di",ao);
}
else
{
if(ao>0)
{
printf("%d+%di",thuc,ao);
}
else if(ao<0) printf("%d%di",thuc,ao);
else printf("%d",thuc);
}
}
// dinh nghia toan tu chong
friend Complex operator*(const Complex& x,const Complex& y);
friend Complex operator+(const Complex& x,const Complex& y);
friend Complex operator-(const Complex& x,const Complex& y);
private: