#include <iostream.h>
class Complex
{
public:
Complex(float re, float im) : myReal(re), myImag(im){}
friend istream& operator>>(istream&, Complex&);
friend ostream& operator<<(ostream&, const Complex&);
private:float myReal;
float myImag;
};
istream& operator>>(istream& in, Complex& c)
{
double real, imag;
in >> real >> imag;
if (in.good())
{
c.myReal = real;
c.myImag = imag;
}
return in;
}
ostream& operator<<(ostream& out, const Complex& c)
{
out << "(" << c.myReal << "," << c.myImag << ")";
return out;
}
void main()
{
// Add more statements here.
}
I wondered what the output for this code. I've been trying to call the functions available in the class of "Complex" by function "main", but to no avail. So, can you add the code in the function "main"? where it will call the functions in the class of "Complex" so that I can see the output for this code and how it works. Thank you.