Hey i’m writing a game in C++ and i don’t understand what type of arguments the save function takes. I assumed you would use the file name for the arguments but i just get an error.
4 IntelliSense: a reference of type “std::ofstream &” (not const-qualified) cannot be > initialized with a value of type “const
char [9]” c:\Users\Conor\Documents\College\C++
Programming\Marooned\Marooned\MainApp.cpp 13 13 Marooned
void MenuText::print()
{
cout<< "Story= " << mText<< endl;
cout<< endl;
}
void MenuText::save(ofstream& outFile)
{
outFile<< "Story = " << mText<< endl;
outFile<< endl;
}
void MenuText::load(ifstream& inFile)
{
string garbage;
inFile>> garbage >> mText;
}
Can anyone help me understand what type of arguments does it take?
It seems that you are calling the
savefunction with a literal string (the filename I guess by the error message). You should call it with an existingofstreaminstead.Something like