c++ program to add 2 complex number using operator
overloading technique
Answer Posted / sundari.b.v
#include<iostream.h>
#include<conio.h>
class complex
{
float x;
float y;
public:
complex(){}
complex(float real,float imag)
{
x=real;
y=imag;
}
complex operator+(complex);
void display(void);
};
complex complex::operator+(complex c)
{
complex temp;
temp x=x+c.x;
temp y=x+c.y;
return
}
void complex::display(void)
{
cout<<x<<"+j"<<y<<"\n";
}
int main()
{
complex c1,c2,c3;
c1=complex(2.5,3.5);
c2=complex(1.6,2.7);
c3=c1+c2;
cout<<"c1=",c1.display();
cout<<"c2=",c2.display();
cout<<"c3=",c3.display();
return 0;
}
| Is This Answer Correct ? | 23 Yes | 6 No |
Post New Answer View All Answers
is vertical heat exchanger has better heat transfer coefficient than horizontal heat exchanger?
Book for preparation of HPCL (CS/IT) .
If Q is the point of ABCD rectangle where QA=3CM,QB=4CM,and QC=5cm then find the length of QD ?
sir can you send me previous question paper of jsplGET entrance test
difference between pvc and gi pipes?
Discussion Topic: “Statutory Defintions” Discussion Questions: Q1 Is it correct that a loan or an advance by a private limited company to a shareholder of the company is considered as payment of dividend? Explain your views. Q2 Will a loan or advance by a private limited company to its holding company be considered as payment of dividend if the subsidiary possesses sufficient amount of accumulated profits?
what is theaverage weight of one brick?
I have cleared sbi clerk and have interview in 26/04/2010.But I am M.Ed & B.Ed,i want to u know my answed about not chose the teaching post
What are the most asked questions for learner operators in the interview for eskom?
the servents of india society was founded by ?
c program to compare the initial portions of the two strings and return the matched portion if matches, otherwise return the empty string.
please i need nautical science past question and answer
.students decide to gift principal 4200 rupees. if teachers give 50% more than the students and an external person gives 3 times to that of teachers.how much do teachers give.
how to resize the components?
plz send me bhel paper....