I am trying to overload both cout from iostream and fout from fstream
ostream& operator<<(ostream& cout, const Object& obj);
ofstream& operator<<(ofstream& fout, const Object& obj);
I want the first function to work with the console so have text for the user while I want the second function to only output the value of the variables onto a file.
However, in
void save_data(const Object& obj)
{
fstream fout("DataBase.txt", ios::out);
if (fout.is_open())
{
fout << obj;
fout.close();
}
else
cout << "DataBase.txt could not be saved!" << endl;
}
I have text that I used to guide the user inside my function that overloads cout in my file.