I'm trying to achieve something like the following:
Logger::Instance() << "Something sent to log file" << std::endl;
If Instance() is defined as
then the followingCode:Logger* Logger::Instance() { return m_pInstance ? m_pInstance : (m_pInstance = new Logger); }
results inCode:template<typename T> Logger& operator<<(T const& data) { //fout is ofstream fout << data; return *this; }
error C2296: '<<' : illegal, left operand has type 'Logger *'
This error make sense, but I can't think of a way around it. Can this type of effect be achieved?




Reply With Quote