我正在尝试为基因测序项目构建16个不同的后缀树。他们正在建造的主这样将ifstream传递给C++中的函数
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:
suffix.cpp: In constructor
Tree::Tree(std::ifstream&)
:
suffix.cpp:12: error: invalid use of undefined typestruct std::basic_ifstream<char, std::char_traits<char> >
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:89: error: declaration ofstruct std::basic_ifstream<char, std::char_traits<char> >
suffix.cpp:15: error: invalid use of undefined typestruct std::basic_ifstream<char, std::char_traits<char> >
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iosfwd:89: error: declaration ofstruct std::basic_ifstream<char, std::char_traits<char> >
+1。 'std :: basic_ifstream'已在''中转发,但''实际上并未包含在代码所在的源文件中。 –
2010-02-23 02:17:40
我将它包含在我的主文件中,但不包含在有问题功能的文件中。谢谢您的帮助。 – 2010-02-23 02:19:52