IFSTREAM通过参数(IFSTREAM through parameter)
我有一个通用的读取功能:
vector <string> GenericRead(ifstream &fin);
并且功能:
int Rule(ifstream &fin) { vector <string> obj2=GenericRead(fin); }
主要:
ifstream fin; fin.open("ex.txt"); vector<string>obj=GenericRead(fin); // works fine Rule(fin) // no longer works, there are no elements in the function vector
任何具有相同结果函数向量的解决方案?
I have a generic read function:
vector <string> GenericRead(ifstream &fin);
And a function:
int Rule(ifstream &fin) { vector <string> obj2=GenericRead(fin); }
Main:
ifstream fin; fin.open("ex.txt"); vector<string>obj=GenericRead(fin); // works fine Rule(fin) // no longer works, there are no elements in the function vector
Any solution to have the same result function vector?
原文:https://stackoverflow.com/questions/31722665
更新时间:2022-08-09 10:08