输入struct std :: basic_ifstream <char,std :: char_traits <char =“”>&gt;没有名为end </char,>的组件

时间:2014-11-16 17:12:57

标签: c++ eclipse stl ifstream

这真让我心烦意乱。我在eclipse中使用ifstream:

infile = new std::ifstream(filePathParam, std::ios::in | std::ios::binary);

但是当我想在简单end中访问seekg()常量时,如下所示:

infile->seekg (0,infile->end)

它显示以下错误:

Type struct std::basic_ifstream<char, std::char_traits<char> > has no component named end  
Type struct std::basic_ifstream<char, std::char_traits<char> > has no component named end  
Type struct std::basic_ifstream<char, std::char_traits<char> > has no component named end

但如果我在调试过程中将鼠标悬停在infile->end属性上,我可以看到声明!:

/// Request a seek relative to the current end of the sequence.
static const seekdir end =      _S_end;

那么问题是什么?!我真的需要帮助,因为如果我不能加载一个简单的文件,它就会停止工作。

由于

编辑: @timrau ,这是创建ifstream对象的地方:

Lector::Lector(char* filePathParam, char* savePathParam)
{
    //infile = new std::ifstream(filePathParam,std::ifstream::binary);
    cout<<"File path param = "<<filePathParam<<endl;
    cout<<"Save Path param = "<<savePathParam<<endl;
    infile = new std::ifstream(filePathParam, std::ios::in | std::ios::binary);
    outfile = new std::ofstream(savePathParam, std::ofstream::binary);

}

这就是我使用seekg()方法的地方:

void Lector::leerArchivo(long divisor,long posicion)
{
    free(textoLeido);
    infile->seekg (0,infile->end);//Sets the position of the next character to be extracted from the input stream.
    ...
}

0 个答案:

没有答案