Hi all
I have a class StreamLogger which implements operator << in this way:
template <class TStreamLogger& operator<<(cons t T& t)
{
<print the stuff using fstream, etc.>
return *this;
}
It works perfectly, using it like:
m_logger << "My ID is " << getID() << "\n";
but for some reason it does not compile this code:
m_logger << std::endl;
It gives the following error:
--------------------------------------------------------------------------------
..\src\Dealer.c pp(70) : error C2678: binary '<<' : no operator found
which takes a left-hand operand of type 'StreamLogger' (or there is no
acceptable conversion)
C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\inc lude
\afx.h(1428): could be 'CDumpContext &operator <<(CDumpConte xt
&,ATL::CTimeSpa n)'
....
--------------------------------------------------------------------------------
Could you guys help me understand why it doesn't compile? (because I
dont have a clue...)
Thanks!!!
Jorge
I have a class StreamLogger which implements operator << in this way:
template <class TStreamLogger& operator<<(cons t T& t)
{
<print the stuff using fstream, etc.>
return *this;
}
It works perfectly, using it like:
m_logger << "My ID is " << getID() << "\n";
but for some reason it does not compile this code:
m_logger << std::endl;
It gives the following error:
--------------------------------------------------------------------------------
..\src\Dealer.c pp(70) : error C2678: binary '<<' : no operator found
which takes a left-hand operand of type 'StreamLogger' (or there is no
acceptable conversion)
C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\inc lude
\afx.h(1428): could be 'CDumpContext &operator <<(CDumpConte xt
&,ATL::CTimeSpa n)'
....
--------------------------------------------------------------------------------
Could you guys help me understand why it doesn't compile? (because I
dont have a clue...)
Thanks!!!
Jorge
Comment