std::ifstream problem

Started by
2 comments, last by EmrldDrgn 17 years, 7 months ago
I'm using (or rather, trying to use) std::ifstream for some file input. I'm getting this compile-time error, which has me stumped:

Error	1	error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'	c:\program files\microsoft visual studio 8\vc\include\fstream	933

Here is the code which interacts with it, as well as the declaration:

std::ifstream file;
	file.open(loader.str().c_str(), std::ios_base::in);
	if(!(file.good()))
		return false;
	file.get(CurrentChars.front());
	do {
		if(CurrentChars.front() == '<')
		{
			METADATA = true;
		}
		else if (CurrentChars.front() == '{')
		{
			Char_iterator = CurrentChars.begin();
			do {
				file.get(*(Char_iterator));
				Char_iterator++;
			} while (CurrentChars.back() != '}');
		}
		if (METADATA)
			if(!(ProcessMetaData (file, CurrentChars)))
				return false;
		else
			if(!(ProcessData (file, CurrentChars)))
				return false;
		file.get(CurrentChars.front());
	} while (CurrentChars.front() != '#');

METADATA is a bool, char_iterator is a std::vector<char>::iterator, and CurrentChars is a std::vector<char>. Any help will be appreciated. I'll keep trying to find it on my own, but it's kinda wierd... anyway, thanks in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~I program in C++, on MSVC++ '05 Express, and on Windows. Most of my programs are also for windows.
Advertisement
Are you sure the error is coming from this block of code? Which line? I tried compiling it under VC6 and didn't get any errors.
I have to agree with Desdamona. I just compiled the below with MSVC++ 2005 Express which you say you are using, and it compiled without errors. I obviously had to add some stuff for all the variables and functions.

#include <fstream>#include <vector>#include <sstream>using namespace std;bool METADATA;vector<char> CurrentChars;stringstream loader;vector<char>::iterator Char_iterator;bool ProcessMetaData(ifstream &is,vector<char> &c){	return false;}bool ProcessData(ifstream &is,vector<char> &c){	return false;}int main(int,const char **av){std::ifstream file;	file.open(loader.str().c_str(), std::ios_base::in);	if(!(file.good()))		return false;	file.get(CurrentChars.front());	do {		if(CurrentChars.front() == '<')		{			METADATA = true;		}		else if (CurrentChars.front() == '{')		{			Char_iterator = CurrentChars.begin();			do {				file.get(*(Char_iterator));				Char_iterator++;			} while (CurrentChars.back() != '}');		}		if (METADATA)			if(!(ProcessMetaData (file, CurrentChars)))				return false;		else			if(!(ProcessData (file, CurrentChars)))				return false;		file.get(CurrentChars.front());	} while (CurrentChars.front() != '#');	return 0;}


Problem must be either in your own declarations, or elsewhere.
Ugh. I dropped the ampersands on the function declarations and definitions. It's amazing how long you can spend looking for two missing &'s... thanks for the help!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~I program in C++, on MSVC++ '05 Express, and on Windows. Most of my programs are also for windows.

This topic is closed to new replies.

Advertisement