I'm trying to declare an ifstream intended to be opened upon a function call (I enter a filename into the program and then the ifstream opens), but every time I get a "use of deleted function" error. Could someone explain or help?
int main()
{
ArrayList<string>* filter;
ArrayList<Star> starDB = ArrayList<Star>();
ArrayList<Planet> pdb = ArrayList<Planet>();
string filename = string();
ifstream inf; //ifstream in question
char inp;
float inum = -1.0;
char sortedBy = '0';
cout << "Welcome to ExoPlanIt. Please enter the name of a planetary system file to upload it." << endl;
cin >> filename;
starDB.append(addSystem(filename, inf, filter));
pdb += starDB[starDB.getSize() - 1].getPlanets();
while(true)
{
/.../
elseif(inp == 'A')
{
try
{
cin >> skipws >> filename;
starDB.append(addSystem(filename, inf, filter)); //addSystem is the function that opens the isftream
pdb += starDB[starDB.getSize() - 1].getPlanets();
cin >> skipws >> inp;
}
catch(ios_base::failure& ff)
{
cout << "Error: File could not be opened." << endl;
}
}
/.../
}
}
I should mention that I get a similar error (same type, different details) when I try to instantiate the ifstream in main with a default constructor (ifstream()).