 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris Theis Guest
|
Posted: Mon Nov 28, 2005 12:57 pm Post subject: fstream constructor |
|
|
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
|
Posted: Mon Nov 28, 2005 1:53 pm Post subject: Re: fstream constructor |
|
|
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
|
Posted: Mon Nov 28, 2005 4:28 pm Post subject: Re: fstream constructor |
|
|
"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 |
|
 |
|
|
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
|
|