Xcode to visual studio discrepencies

Hi,

I have written a code for a class which i have defined within a header file which is part of a namespace 'myns1',the memeber functions of the class are defined in a source file and then the main code is within another source file. I am able to get it to run on visual studio, but when i attempt to compile it within xcode i get an error on a function overloading the << operator. Within the header file i have declared it as a friend, coded as

friend std::ostream & operator<<(std::ostream &os, const complex &v);

then withing the source file containing the functions, the full function is

ostream & myns1::operator<<(ostream &os, const complex &v)
{
if(v.getim()>=0)
{

os<<"("<<v.re<<"+"<<v.im<<"i)";
return os;
}
else
{
os<<"("<<v.re<<v.im<<"i)";
return os;
}
}

As i said the whole code compiles fine within visual studio, but when i compile it in Xcode, i get the following error.

'std::ostream& myns1::operator<<(std::ostream&, const myns1::complex&)' should have been declared inside 'myns1'

As i said the class is part of a namespace myns1. I was just wondering if anybody might know if there is alternative method used in xcode when declaring certain functions.


Thanks

Michael


Are you sure that myns1::operator << is defined in your header? If so, have you included this header?
Topic archived. No new replies allowed.