operator<< overload problem
I created complex class:
Code:
class CComplex
{
private:
double m_dReal;
double m_dImage;
public:
CComplex() :m_dReal(0),m_dImage(0){}
CComplex(double re, double im=0) :m_dReal(re),m_dImage(im){}
CComplex(const CComplex& x):m_dReal(x.getReal()),m_dImage(x.getImage()){}
double getReal () const {return m_dReal;}
double getImage ()const {return m_dImage;}
CComplex operator+ (const CComplex& r)const;
CComplex& operator+= (const CComplex& r);
CComplex operator* (const CComplex& r)const;
CComplex& operator*= (const CComplex& r);
CComplex& operator= (const CComplex& r);
bool operator== (const CComplex& r) const;
bool operator!= (const CComplex& r) const;
friend ostream& operator << (ostream& ro, const CComplex& r);
};
when trying to compile i got the following error:
ISO C++ forbids declaration of `ostream' with no type
complex.H:34: error: `ostream' is neither function nor member function; cannot be declared friend
complex.H:34: error: expected `;' before '&' token
complex.C: In function `std::ostream& operator<<(std::ostream&, const CComplex&)':
can't find what's wrong....