Reputation: 135
I was looking for any way to convert a file which has ASCII art or any other way. I saw a program online but there was an error with the reader.
Severity Code Description Project File Line Suppression State Suppression State Error (active) E1776 function "std::basic_ifstream<_Elem, _Traits>::basic_ifstream(const std::basic_ifstream<_Elem, _Traits> &) [with _Elem=char, _Traits=std::char_traits]" (declared at line 879 of "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include\fstream") cannot be referenced -- it is a deleted function CA C:\Users\jorda\OneDrive - Limerick Institute Of Technology\College\Semester 5\Game Programming\CA\CA\Event.cpp 17
Any help is appreciated
string Art:: getArt(ifstream File)
{
string Lines = ""; //All lines
if (File) //Check if everything is good
{
while (File.good())
{
string TempLine; //Temp line
getline(File, TempLine); //Get temp line
TempLine += "\n"; //Add newline character
Lines += TempLine; //Add newline
}
return Lines;
}
else //Return error
{
return "ERROR File does not exist.";
}
}
void Art::yo()
{
ifstream Reader("Orc1.txt");
string readArt = getArt(Reader);
}
Upvotes: 0
Views: 393
Reputation:
You can't pass std::ifstream
s or std::ofstream
s by value. You need to pass them by reference:
std::string Art:: getArt(std::ifstream& File)
Upvotes: 1