L
Laxman
==C.H <==
#include <fstream.h>
class C
{
public:
C(int i);
friend ofstream& operator<<(ofstream& os, const C&);
};
------------------------------------------------------------
==B.H <==
#include <fstream.h>
#include "C.H"
class B
{
public:
friend ofstream& operator<<(ofstream& os, const B&);
};
------------------------------------------------------------
==B.C <==
#include "B.H"
ofstream& operator<<(ofstream& 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_ostream<char, std::char_traits<char>>:perator<<(int)"
and "operator<<(std::basic_ofstream<char, std::char_traits<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<<(ofstream& os, const C&);
};
------------------------------------------------------------
==B.H <==
#include <fstream.h>
#include "C.H"
class B
{
public:
friend ofstream& operator<<(ofstream& os, const B&);
};
------------------------------------------------------------
==B.C <==
#include "B.H"
ofstream& operator<<(ofstream& 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_ostream<char, std::char_traits<char>>:perator<<(int)"
and "operator<<(std::basic_ofstream<char, std::char_traits<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 ?