Hi,everyone
I have to write a calculator which can + , - , * , / , + = ,- = , * = , /= ,++,-- do this operations with operator overloading
#include<iostream>
using namespace std;
class complexNumber
{
private:
double realPart;
double imaginaryPart;
public:
complexNumber(){realPart=0.0; imaginaryPart=0.0;}
~complexNumber(){cout<<"Destructor do it's work..!"<<endl;}
double get_real(){return realPart;}
double get_imaginary(){return imaginaryPart;}
void set_real(double r){realPart=r;}
void set_imaginary(double i){imaginaryPart=i;}
complexNumber operator+(const complexNumber& c);
complexNumber operator-(const complexNumber& c);
};
void main()
{
complexNumber c1,c2,c3;
c1.set_real(3.4);
c1.set_imaginary(4.5);
c2.set_real(5.6);
c2.set_imaginary(6.2);
c3= c1 + c2;
cout<< c1 <<endl<< c2 <<endl<< c3 <<endl;
}
i wrote that code according to some topics in this forum but it gives me a error
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class complexNumber' (or there is no acceptable conversion)
How can i fix this?
Also i have to write a display function to print complex numbers according to my code i can not do it please also help me in this problem...
Have a good day...
P.S. i have just registered yet sorry if i did sth wrong...:rolleyes: