trying to write std:out and file at the same time
问题 I am trying to write to file and stdout at the same time within c++ by overloading ofstream test.h #pragma once #include <iostream> using std::ofstream; class OutputAndConsole:public ofstream { public: std::string fileName; OutputAndConsole(const std::string& fileName):ofstream(fileName),fileName(fileName){ }; template <typename T> OutputAndConsole& operator<<(T var); }; template <typename T> OutputAndConsole& OutputAndConsole::operator<<(T var) { std::cout << var; ofstream::operator << (var)