-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinary_P7.cpp
More file actions
53 lines (53 loc) · 1.08 KB
/
Binary_P7.cpp
File metadata and controls
53 lines (53 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<iostream.h>
#include<conio.h>
class binary
{
public:
int r, i;
void get( );
binary operator +(binary);
void display( );
};
void binary::get( )
{
cout<<"\n Enter the Real Part: ";
cin>>r;
cout<<"\n Enter the Imaginary Part: ";
cin>>i;
}
binary binary::operator +(binary d)
{
binary c;
c.r=r+d.r;
c.i=i+d.i;
return c;
}
void binary::display( )
{
cout<<"\t"<<r<<"+"<<i<<"i";
}
void main( )
{
binary b1, b2, b3;
clrscr( );
cout<<"\n\t\t BINARY OPERATOR OVERLOADING";
cout<<"\n\t\t ***************************";
cout<<"\n\nEnter the first complex number ";
cout<<"\n-------------------------------";
b1.get( );
cout<<"\n\nEnter the second complex number ";
cout<<"\n--------------------------------";
b2.get( );
cout<<"\n\nSum of two complex numbers ";
cout<<"\n--------------------------------";
b3=b1+b2;
cout<<"\n\n First complex number : ";
b1.display( );
cout<<"\n Second complex number : ";
b2.display( );
cout<<"\n\t\t\t----------------";
cout<<"\n Sum : ";
b3.display( );
cout<<"\n\t\t\t----------------";
getch( );
}