c++vectorifstream

Vector of ifstreams


How can I create and manipulate a vector of ifstreams?

Something like this, except this doesn't work:

vector<ifstream> Files(10, ifstream());
Files[0].open("File");

Solution

  • The closest I can think of is vector<shared_ptr<ifstream> > — you can't put ifstreams in vector as they're not copy-constructible.