My project has around 50 files, I already search all header files to check if any function pass fstream as argument, and modify them all to be passed as reference instead of as object.
I don't understand why if I use following code:
ifstream fin(OutputF, ios::in,ios::nocreate);
I got error like "C2039: 'nocreate' : is not...", but if I modify it to:
ifstream fin(OutputF, ios::in,ios::_Nocreate);
I got other kind of error messge:
"error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private.."
Wait, if you're doing an ifstream (input), why are you specifiying "no create" at all? That doesn't make sense, it's not going to get created if it can't find it. That's only even applicable at all if you're opening in read/write or write modes.
I solve my issue posted yesterday, but today has another problem related to it.
When I migrate another small project from C++ to VS2008, I double check all the function delcaration to make sure fstream object is passed by reference or pointer, but when I compile program, I still got two error messages, they are same and the only two errors.
C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
In this case how should I find where the error come from?
I would suppose that passing the fstream by value in 6.0 was wrong too. It might have worked but only by luck.
A fstream is a representation of a computer resource. Passing by value implicitly duplicates the representation without duplicating the actual resource. Thus it represents a broken design/implementation.