==C.H <==
#include <fstream.h>
class C
{
public:
C(int i);
friend ofstream& operator<<(ofst ream& os, const C&);
};
------------------------------------------------------------
==B.H <==
#include <fstream.h>
#include "C.H"
class B
{
public:
friend ofstream& operator<<(ofst ream& os, const B&);
};
------------------------------------------------------------
==B.C <==
#include "B.H"
ofstream& operator<<(ofst ream& os, const B& b)
{
int i = 1;
os << i;
return os;
}
------------------------------------------------------------
CC -c B.C
"B.C", line 6: Error: Overloading ambiguity between
"std::basic_ost ream<char, std::char_trait s<char>>::opera tor<<(int)"
and "operator<<(std ::basic_ofstrea m<char, std::char_trait s<char>>&,
const C&)"
To make it easier I have trimmed down and kept only the necessary
code
to create the error.
BTW this works fine with g++ but fails with Sun Forte Compiler.
Any idea what the problem is ?
#include <fstream.h>
class C
{
public:
C(int i);
friend ofstream& operator<<(ofst ream& os, const C&);
};
------------------------------------------------------------
==B.H <==
#include <fstream.h>
#include "C.H"
class B
{
public:
friend ofstream& operator<<(ofst ream& os, const B&);
};
------------------------------------------------------------
==B.C <==
#include "B.H"
ofstream& operator<<(ofst ream& os, const B& b)
{
int i = 1;
os << i;
return os;
}
------------------------------------------------------------
CC -c B.C
"B.C", line 6: Error: Overloading ambiguity between
"std::basic_ost ream<char, std::char_trait s<char>>::opera tor<<(int)"
and "operator<<(std ::basic_ofstrea m<char, std::char_trait s<char>>&,
const C&)"
To make it easier I have trimmed down and kept only the necessary
code
to create the error.
BTW this works fine with g++ but fails with Sun Forte Compiler.
Any idea what the problem is ?
Comment