Singleton and operator

Discussion in 'C++' started by inspiration, Jun 3, 2010.

  1. inspiration

    inspiration New Member

    Joined:
    Feb 15, 2010
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    0
    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: : Confused:
     
  2. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    http://ipankaj.net
    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 ();
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice