Hi All
This is more a discussion than a problem. :)
I’m working on a small project that needs to be done in C++.
Part of it requires that I maintain an array of file streams so that I can open serveral files at one time, read, write exchange data as often as I need to and close them when done.
So dusting of some of my old C++ books (these days my coding is done all in C++ CLI/CLR) and read up on the fstream class. Ah! yes istream for reading ostream for writing, bugger two streams! What to do?
Back in the old C days I could use:
FILE *fp[20];
fp[0] = fopen(“filename”, “rb+”);
Nowadays in CLR
Array<FileStream^>^ fp = gcnew array<FileStream^>(20);
fp[0] = gcnew FileStream(“filename”, FileMode::Open, FileAccess::ReadWrite);
Is seems C++ does not have a stream class that supports a read/write in the same open mode. Or should I do some more reading :)
I’ve knock up some testing code using the older C style “FILE” and this worked great, just as I expected it would.
Question
Is it “acceptable” amongst even the purest of C++’s programmers to mix old C style code in with the OOP style of C++, or should I re-think my design working around the C++ fstream class.
Open for discussion.
Milton
:)