I'm trying to make a logger which logs to std::cout and to a file. This is my class:
.h file:
class ProblemsManager {
        (...)
private:
        (...)
    class logger {
    private: 
        std::ofstream fileStream;
        static const std::string LOG_PATH;
    public: 
        logger();
        ~logger();
    template<class T> 
    friend logger & operator<<(logger &log, const T & bytes) {
        log.fileStream<<bytes;
        std::cout<<bytes;
        return log;
    }
    };
};
.cpp file
(...)
const std::string ProblemsManager::logger::LOG_PATH = "F:\\Dropbox\\workspace - Visual Studio\\PEuler\\PEuler\\PEuler.log";
ProblemsManager::logger::logger() : fileStream(LOG_PATH,std::ofstream::out) {}
ProblemsManager::logger::~logger() {}
Then if I try to do:
ProblemsManager::logger log;
log<<"test";
I get:
1>f:\dropbox\workspace - visual studio\peuler\peuler\problemsmanager.cpp(47): error C3767: '<<': candidate function(s) not accessible 1> could be the friend function at 'f:\dropbox\workspace - visual studio\peuler\peuler\problemsmanager.h(37)' : '<<' [may be found via argument-dependent lookup]
 
     
    