Saturday, May 9, 2009

C++ ifstream stream question?

This is my function:


DU_parser::DU_parser(const string %26amp; filename)


{


this -%26gt; filename = filename;


ifstream in;


in.open(filename); //Line 35


...


...


...}





this is my error:


ian@ian-laptop:~/Desktop/assn5_framewo... make


g++ -W -Werror -Wall -pedantic -ansi -c -o du_parser.o du_parser.cpp


du_parser.cpp: In constructor ‘DU_parser::DU_parser(const std::string%26amp;)’:


du_parser.cpp:35: error: no matching function for call to ‘std::basic_ifstream%26lt;char, std::char_traits%26lt;char%26gt; %26gt;::open(const std::basic_string%26lt;char, std::char_traits%26lt;char%26gt;, std::allocator%26lt;char%26gt; %26gt;%26amp;)’


/usr/lib/gcc/i486-linux-gnu/4.1.2/../.... note: candidates are: void std::basic_ifstream%26lt;_CharT, _Traits%26gt;::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits%26lt;char%26gt;]


make: *** [du_parser.o] Error 1








Can anyone help me, please? Thanks a ton!


-Ian

C++ ifstream stream question?
Did you include fstream.h at the top of the code?


No comments:

Post a Comment