// classA.cpp #include classA.h A::A(void) : _logfile(0) { std::ofstream output("logfile.txt",std::ofstream::app); _logfile = &output; } A::dosomething(void) { *_logfile << "Print something" << std::endl; }