Sign in to follow this  
EmrldDrgn

std::ifstream problem

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this