Fstream declaration
I need to be able to use a function multiple times with a differe开发者_开发知识库nt file. I have this piece of code:
fstream in(inf, ios::in);
where inf is a string with a .mpp extension, and it doesn't work (the declaration) 
can you please help me? :)
You probably want:
 fstream in(inf.c_str(), ios::in);
Better yet, use an ifstream:
string mpp = "foobar.mpp";
ifstream in( mpp.c_str() );
I don't understand why people don't use the specialised input and output streams when they only want to perform one of input or output.
As I may infer of your "doesn't work" responses, maybe you have to:
a) Include the fstream header.
b) Use std:: prefix for fstream (or ifstream)
#include <fstream>
// ...
std::ifstream in (inf.c_str());
(note that if you use ifstream you don't have to specify ios::in)
Hmm.
Maybe try to wrap this function in some file hanlder object. Then just include file handler header in working files and use as much as you like..
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论