Hi, ich habe folgendes problem: I have the following problem: Ich hab einen Singleton einer klasse und diese klasse hat halt nen << operator. I have a singleton of a class and this class has just NEN <<operator. Doch beim Compilieren bekomm ich folgenden Error: But while compiling I get the following error: Code: error C2296: '<<': illegal, left operand has type 'class Clog *' error C2297: ' << ' : illegal, right operand has type ' char [5] ' error C2297: '<<': illegal, right operand has type 'char [5]' Here's the code: Code: / / CLog.h class CLog class Clog { ( public : public: static CLog *getInstance ( void ) { return (&m_Instance); } static Clog * getInstance (void) (return (& m_Instance);) void setFile ( const char *FileName = " Protokoll.htm "); void setFile (const char * FileName = "Protokoll.htm"); CLog& operator << ( void * n); Clog & operator <<(void * s); private : private: CLog ( void ); Clog (void); static CLog m_Instance; static Clog m_Instance; std::ofstream m_Stream; std:: ofstream m_Stream; }; ); Code: # Include "CLog.h" CLog CLog::m_Instance; Clog Clog:: m_Instance; CLog::CLog( void ) Clogs:: Clogs (void) { ( } ) CLog& CLog:: operator << ( void * n ) Clogs & Clog:: operator <<(void * s) { ( this ->m_Stream << n; this -> m_Stream <<n; return (* this ); return (* this); } ) and here the main.cpp: Code: # Include "CLog.h" int main ( void ) int main (void) { ( CLog *p_Protokoll; Clog * p_Protokoll; p_Protokoll = CLog::getInstance (); p_Protokoll = Clog:: getInstance (); p_Protokoll << " Test " << std::endl; p_Protokoll <<"Test" <<std:: endl; return ( false ); return (false); } ) I have to rebuild the Singleton or how I get the <<operators, to the run it? : Confused:
you work with in the refernzen or dereferenzierst pointer Code: int main (void) { ( CLog *p_Protokoll; Clog * p_Protokoll; p_Protokoll = CLog::getInstance (); p_Protokoll = Clog:: getInstance (); *p_Protokoll << " Test " << std::endl; * P_Protokoll <<"Test" <<std:: endl; return ( false ); return (false); } ) Code: Clog * p_Protokoll; p_Protokoll = CLog::getInstance (); p_Protokoll = Clog:: getInstance ();