thank you tom.
The purpose is the operator >> For read a completly line in one string
variable.
<< isn't need...
fred
"tom_usenet" <tom_usenet@hotmail.com> schrieb im Newsbeitrag
news:39oesv8tpcuiim1c2bqh21e2v9m0gqai6c@4ax.com...[color=blue]
> On Fri, 28 Nov 2003 11:07:30 +0100, "Frédéric Manzanares"
> <fm29@gmx.net> wrote:
>[color=green]
> >hello,
> >
> >my problem: I want to habe one Class with write and read in a file. i[/color][/color]
have[color=blue][color=green]
> >overloaded
> >the operator >> and <<.
> >
> >class c_File[/color]
>
> What is the purpose of c_File? What does it offer over std::fstream?
> There may be a better solution than defining a new class that is
> unrelated to fstream.
>[color=green]
> >{
> >public :
> > fstream fs;
> >.....
> > public :
> >...
> >friend void operator >> (c_File& ,string& );
> >friend void operator << (c_File& ,const char * );
> >...
> >}
> >void operator <<(c_File& myFile, const char* out )
> >{
> > myFile.fs<<out;
> >}
> >void operator >>(c_File& myFile, string& out)
> >{
> >int c;
> >string s;
> > getline(myFile.fs,s);
> > out=s;
> >}
> >
> > main.C
> >{
> > c_File oFile;
> > string s;
> > oFile.OpenFile("file_sample.txt",ios::in|ios::out| ios::app );
> > oFile<<"hey baby!";
> > oFile>>s;[/color]
>
> The read and write position are shared for fstream. You need to do:
>
> fstream oFile("file_sample.txt",ios::in|ios::out|ios::app );
> string s;
> oFile<<"hey baby!";
> oFile.seekg(0, ios::beg); //seek back to start.
> oFile>>s;
>
> Tom
>
> C++ FAQ:
http://www.parashift.com/c++-faq-lite/
> C FAQ:
http://www.eskimo.com/~scs/C-faq/top.html[/color]