ファイルがあり、その内容を印刷したいのですが、機能を動作させることができません。
これが私のコードです:
int main()
{
MenuText text;
string test = "Champion";
ofstream output("File.txt");
text.save(output);
fstream output ("File.txt");
text.load("File.txt");//This is an error.
text.print();
MenuText::MenuText()
{
mText = "Default";
}
MenuText :: MenuText(string text)
{
mText = text;
}
void MenuText::print()
{
cout<< "Story= " << mText<< endl;
cout<< endl;
}
void MenuText::save(ofstream& outFile)
{
outFile<< "/ . \ \____ \\ \\ _ -. "
//"/ /__ - \/\_______\\__\\__\ \"
"__\ /\ __ \ . \/_______//__//"
"__/\/__/ \ \ \_\ \ - ________ "
"___ ___ ______ \ \_____/ - /\ "
"__ \\ -.\ \\ ___\ \/_____/ ."
"\ \ \__\ \\ \-. \\ __\_ "
"- \ _\_______\\__\ `\___\\_____\ "
". \/_______//__/ /___//_____/ "<< mText<< endl;
cout<< endl;
outFile<< endl;
}
void MenuText::load(ifstream& inFile)
{
string garbage;
inFile>> garbage >> mText;
}
The errors are:
Error 1 error C2371: 'output' : redefinition; different basic types c:\users\conor\documents\college\c++ programming\marooned\marooned\mainapp.cpp 15 1 Marooned
Error 2 error C2664: 'MenuText::load' : cannot convert parameter 1 from 'const char [9]' to 'std::ifstream &' c:\users\conor\documents\college\c++ programming\marooned\marooned\mainapp.cpp 16 1 Marooned