• Advertisement
Sign in to follow this  

std::ifstream problem

This topic is 4149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

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
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement