These days I've studied operator overloading and after that I tried to overload >> operator with ifstream for files.
I'm wondering why this program doesn't show me the data I'm trying to get from the file dati.it USING THE OP. OVERLOADING. Without the function ifstream& operator>>(ifstream& c, string& s) it works fine, but I want to do the job with the overloading

#include <iostream> #include <fstream> using namespace std; ifstream& operator>>(ifstream& c, string& s) { c >> s; return c; } int main() { const int dim_max = 1000; char name[dim_max]; char surname[dim_max]; char email[dim_max]; string lista; // 1.input cin.getline(name, dim_max, '\n'); cin.getline(surname, dim_max, '\n'); cin.getline(email, dim_max, '\n'); // writing to file ofstream Fileobj; Fileobj.open("dati.txt"); Fileobj << name << endl << "#" << endl << surname << endl << "#" << endl << email << endl << "#" << endl; Fileobj.close(); // 2.output ifstream Fileobjx("dati.txt"); while (!Fileobjx.eof()) { Fileobjx >> lista; cout << lista; } cout << "Ok" << endl; return 0; }