M
Martin Eisenberg
What do I need to make this work?
#include <iostream>
#include <fstream>
using namespace std;
struct LoggedCout {
ofstream file;
LoggedCout(const char* name) : file(name, ios::app) {}
template<class T>
LoggedCout& operator<<(const T& t)
{ cout << t; file << t; return *this; }
};
LoggedCout lout("flushtest.txt");
int main() {
lout << "output";
lout << flush;
// no match for 'operator<<' in 'lout << std::flush'
{ char c; cin >> c; }
return 0;
}
Martin
#include <iostream>
#include <fstream>
using namespace std;
struct LoggedCout {
ofstream file;
LoggedCout(const char* name) : file(name, ios::app) {}
template<class T>
LoggedCout& operator<<(const T& t)
{ cout << t; file << t; return *this; }
};
LoggedCout lout("flushtest.txt");
int main() {
lout << "output";
lout << flush;
// no match for 'operator<<' in 'lout << std::flush'
{ char c; cin >> c; }
return 0;
}
Martin