Error C2079 Ofstream
Development > C++ Standards, Extensions, and Interop Question 0 Sign in to vote Hi, all. I can't figure out why this simple console program does not compile. All I want to do is create a fstream. The code is below:#include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up C++ compiler error with stringbuf / ifstream up vote 1 down vote favorite I cannot understand why my compiler https://social.msdn.microsoft.com/Forums/vstudio/en-US/0b6174ad-bcfd-4863-b83f-bfd64a5f3620/unable-to-create-fstream?forum=vclanguage (MSVC++2010) doesn't like this code: // get_sum(filename as c-string) returns sum from file int get_sum(const char* const s) { stringbuf bill_buf; ifstream bill_file; bill_file.open(s); bill_file.get(bill_buf, '\0'); // read whole file bill_file.close(); return get_sum_from_string(bill_buf.str()); } I get these errors (I translated them from German to English and give the correct line numbers for the code excerpt without leading comment): Error 1 error C2079: 'bill_buf' uses undefined class 'std::basic_stringbuf<_Elem,_Traits,_Alloc>' (Line 2) Error 2 error http://stackoverflow.com/questions/4797747/c-compiler-error-with-stringbuf-ifstream C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::get(_Elem *,std::streamsize)': Conversion of parameter 1 from 'int' to 'char *' not possible (Line 5) Error 3 error C2228: To the left of ".str" there must be a class/structure/union. (Line 7) Has anyone got an idea what's going on there? Thanks a lot! (If anyone has got a better idea how to quickly get the whole file contents into a string, I'd also appreciate it) c++ file-io compiler-errors share|improve this question asked Jan 25 '11 at 19:08 Felix Dombek 3,97863668 2 Errors 2 and 3 are side-effects of #1. Did you specify 'using std'? Do you have the correct header file for stringbuf? –Chris O Jan 25 '11 at 19:10 you're missing an include file that defines stringbug... Now which one was it. –user180326 Jan 25 '11 at 19:11 That's right, I just did include
Forum Visual C++ & C++ Programming Visual C++ Programming ifstream "uses undefined class" If this is your http://forums.codeguru.com/showthread.php?296051-ifstream-quot-uses-undefined-class-quot first visit, be sure to check out the FAQ by clicking the link above. You may have to register or Login before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 3 of 3 Thread: ifstream "uses undefined error c2079 class" Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode May 25th, 2004,12:48 AM #1 code_addict View Profile View Forum Posts Junior Member Join Date May 2004 Posts 2 ifstream "uses undefined class" Hi everyone, I am new to C++, trying to error c2079 ofstream learn it on my own. I am using VC++ 6.0 and I'm trying to create a VERY simple program that replaces string in specified text files. I'm trying to use ifstream for this purpose, but when I try to create an ifstream object like this #include