Since std::eol is actually a function template of the type compatible with ostream& (*fctr) (ostream&)
, you need to overload the following operator:
class FileOut
{
//...
friend FileOut & operator<< (FileOut & obiekt, ostream& (*fctr) (ostream&))
//...
};
Inside the overload, you need to make sure that fctr actually matches eol (it can be eof, tab, or any manipulator matching the signature) and then write whatever it is you want to write to a file on eol:
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
class FileOut
{
private:
std::ofstream stream;
public:
FileOut(std::string sciezka):stream(sciezka) {};
~FileOut(void){};
friend FileOut & operator<< (FileOut & obiekt, const char* w) {obiekt.stream<<w;return obiekt;} ;
friend FileOut & operator<< (FileOut & obiekt, const string & w);
friend FileOut & operator<< (FileOut & obiekt, const char & znak);
friend FileOut & operator<< (FileOut & obiekt, const int & liczba){obiekt.stream<<liczba;return obiekt;};
friend FileOut & operator<< (FileOut & obiekt, const double & liczba);
friend FileOut & operator<< (FileOut & obiekt, ostream& (*pf) (ostream&));
//friend FileOut & endl (FileOut & obiekt);
};
FileOut & operator<< (FileOut & obiekt, ostream& (*pf) (ostream&))
{
if(pf==&std::endl)
{
obiekt.stream<<"MY FAT JUICY EOL";
}
return obiekt;
}
int main(int argc, char* argv[])
{
FileOut save("file.txt");
save<<"tralalala"<<endl<<1123;
return 0;
}