c++ program to add 2 complex number using operator
overloading technique

Answer Posted / a.bharathi raja

#include<iostream.h>
#include<conio.h>
class complex
{
int r;
int i;
public:
complex()
{ }
complex(int a,int b)
{
r=a;i=b;
}
friend complex operator+(complex,complex);
friend show(complex);
complex operator+(complex c1,complex c2)
{
complex c3;
c3.r=c1.r+c2.r;
c3.i=c1.i+c2.i;
return(c3);
}
show(complex c)
{
cout<<c.r<<"i+"<<c.i<<endl;
}
void main()
{
complex a,b,c;
clrscr();
a.complex(3,6);
b.complex(4,7);
c=a+b;
show(a);
show(b);
show(c);
getch()
}

Is This Answer Correct ?    24 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why voltage drops in star connected motor And how IL=ph

1392


sir , please send me previous gate ece questionpapers with explanations.i want 15 years of gate ece question papers

1859


What is the number which when divided by 12,15 and 24 gives remainder 5?

1145


sir can you send me previous question paper of jsplGET entrance test

2017


22. A solution of 1% (w/v) starch at pH 6.7 is digested by 15 μg of β‐amylase (mol wt 152,000). The rate of maltose (mol wt = 342) had a maximal initial velocity of 8.5 mg formed per min. The turnover number is

6215






the servents of india society was founded by ?

1684


how to works epbx? how to configuration the epbx?

1588


If Q is the point of ABCD rectangle where QA=3CM,QB=4CM,and QC=5cm then find the length of QD ?

2565


please i need nautical science past question and answer

2476


c program to compare the initial portions of the two strings and return the matched portion if matches, otherwise return the empty string.

1849


What are the most asked questions for learner operators in the interview for eskom?

1605


can u explain me the way to know the relation between the active as well as the reactive power acting on an electical machine under the under excitation as well as over excitation mode

2113


WHO IS INVITED WIRELESS FIDELITY TECHNOLOGY

1889


why is it important to take m.e mechanical?is our l;ife make happier than other b.e courses only answer no comments

1716


The horse has played a little known but very important role in the field of medicine. Horses were injected with toxins of diseases until their blood built up immunities. Then a serum was made from their blood.Serums to fight with diphtheria and tetanus were developed this way. It can be inferred from the passage, that horses were (A) given immunity to diseases (B) generally quite immune to diseases (C) given medicines to fight toxins (D) given diphtheria and tetanus serums

3082