Static data member doesn't maintain its value

Hi all,
i made static ifstream object but it causes an access violation error, i declared it like this:

1
2
3
// in .h file
private:
	static ifstream reader;


1
2
// in .cpp file
ifstream ClassName::reader ("fileName.txt");


1
2
3
4
5
// error arises here
while (!reader.eof())
	{
	   .....
	}


oh, i forgot something, i already did the same in VS2008 and it worked very well, when i copy the same class in VS2005 project it caused that error

thanks in advance
Last edited on
Have a look through the VS2008 release notes. My guess is that this was a defect in VS2005 that was fixed in the later release.
Topic archived. No new replies allowed.