我正在尝试为基因测序项目构建 16 种不同的后缀树。它们是在 main 中构建的
int main()
{
ifstream fp;
fp.open("filepath", ifstream::in);
Tree I(fp);
fp.close();
我正在尝试使用以下代码在我的构造函数中使用它们:
Tree::Tree(ifstream &fp)
{
string current = "";
char* line;
fp.getLine(line, 100); //ignore first line
for(int i=0; i<100; i++)
{
char temp = (char)fp.get();
if(temp=='\n')i--;
else current+=temp;
}
insert(current);
while(fp.good())
{
current = current.substr(1,99);
char temp = (char)fp.get();
if(temp=='\n')temp=(char)fp.get();
if(temp==EOF) break;
current+=temp;
insert(current);
}
}
当我尝试编译时,对于我使用 fp 的每个实例,我都会收到这些错误:
最佳答案
你#included fstream
header 了吗?
关于c++ - 将 ifstream 传递给 C++ 中的函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2315698/