#include<iostream.h>
#include<conio.h>
class complex{
float a,b;
public:
complex(){
a=b=0;
}
complex(float real,float image){
a=real;
#include<conio.h>
class complex{
float a,b;
public:
complex(){
a=b=0;
}
complex(float real,float image){
a=real;
b=image;
}
void display(){
cout<<a<<"+("<<y<<")i"<<endl;
}
friend void operator-(complex &c);
};
void operator-(complex &c){
c.a=-c.a;
}
void display(){
cout<<a<<"+("<<y<<")i"<<endl;
}
friend void operator-(complex &c);
};
void operator-(complex &c){
c.a=-c.a;
c.b=-c.b;
}
void main(){
complex c1(2,-5);
clrscr();
c1.display();
// Unary Operator overloading
-c1;
c1.display();
getch();
}
}
void main(){
complex c1(2,-5);
clrscr();
c1.display();
// Unary Operator overloading
-c1;
c1.display();
getch();
}
No comments:
Post a Comment