C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

fstream constructor

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Chris Theis
Guest





PostPosted: Mon Nov 28, 2005 12:57 pm    Post subject: fstream constructor Reply with quote



Hello,

as stated by the standard the fstream derivatives (ifstream & ofstream)
expect a const char*
parameter indicating the file name associated with the stream to be opened.
I wondered why there is no constructor accepting a const string& parameter,
which forces the user to convert any filename to an old C-style string
before passing it to the constructor. Is this simply a historical legacy or
is there some deeper problem, which I might fail to see. Probably somebody
could shed some light on this issue.

Thanks
Chris


Back to top
Pete Becker
Guest





PostPosted: Mon Nov 28, 2005 1:53 pm    Post subject: Re: fstream constructor Reply with quote



Chris Theis wrote:
Quote:

as stated by the standard the fstream derivatives (ifstream & ofstream)
expect a const char*
parameter indicating the file name associated with the stream to be opened.
I wondered why there is no constructor accepting a const string& parameter,
which forces the user to convert any filename to an old C-style string
before passing it to the constructor. Is this simply a historical legacy or
is there some deeper problem, which I might fail to see. Probably somebody
could shed some light on this issue.


There are seventeen functions in the C++ standard that take const char*
but don't have analogs that take strings. Versions taking strings will
probably be added in the next standard.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)

Back to top
Chris Theis
Guest





PostPosted: Mon Nov 28, 2005 4:28 pm    Post subject: Re: fstream constructor Reply with quote



"Pete Becker" <petebecker (AT) acm (DOT) org> wrote

Quote:
Chris Theis wrote:

as stated by the standard the fstream derivatives (ifstream & ofstream)
expect a const char*
parameter indicating the file name associated with the stream to be
opened.
I wondered why there is no constructor accepting a const string&
parameter,
which forces the user to convert any filename to an old C-style string
before passing it to the constructor. Is this simply a historical legacy
or
is there some deeper problem, which I might fail to see. Probably
somebody
could shed some light on this issue.


There are seventeen functions in the C++ standard that take const char*
but don't have analogs that take strings. Versions taking strings will
probably be added in the next standard.


Thanks Pete for confirming what I had already expected. I just had expected
that the revision of the standard in 2003 would/could have introduced this,
but naturally there are certainly more important things to cover.

Cheers
Chris



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.