如何使用fstream将文本文件存储在堆栈中

时间:2018-10-29 17:59:54

标签: c++ file stack fstream

#include <iostream>
#include <stack>
#include <fstream>

using namespace std;

int main()
{
   stack <fstream> webpages;
   fstream web1;
   fstream web2;
   fstream web3;

   web1.open("web1.txt",fstream::out);
   web2.open("web2.txt",fstream::out);
   web3.open("web3.txt",fstream::out);

   web1.close();

   webpages.push(web1);
   cout << webpages.size() << endl;

   system("pause");
}

编译程序时出现以下错误:

  

std :: basic_fstream> :: basic_fstream(const   std :: basic_fstream>&):尝试   引用已删除的功能

所以我认为我这样做的方式是错误的。有什么方法可以将fstream文件存储在堆栈中?

0 个答案:

没有答案