By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

File cannot open with ofstream constructor !

P: n/a
hi all,

This is quite puzzling me why is that ofstream constructor is unable
to open a file for writing while, a ofstream "open" method can ! The
c++ book by Herbert Schildt which i m readin mentions that ofstream
default constructor can open a file. But when i tried to open a file
it failed to open. Then i tried it by open method which succeded.
I m using g++ on Redhat linux.

Any insights will be appreciated.
Thanks in advance.
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

tornado <to********@yahoo.com> wrote in message
news:c8**************************@posting.google.c om...
hi all,

This is quite puzzling me why is that ofstream constructor is unable
to open a file for writing while, a ofstream "open" method can !
Show us your code.
The
c++ book by Herbert Schildt
See http://snurse-l.org/acllc-c++/faq.html#q6.4
which i m readin mentions that ofstream
default constructor can open a file.
Did you misread that part, or is this another 'Schildtism'?
Class 'ofstream' does provide a default constructor, but
it certainly does not open a file? Which file would it open?
But when i tried to open a file
it failed to open.
Show us the code you used, and tell us what indicates
to you the open failed.
Then i tried it by open method which succeded.
I m using g++ on Redhat linux.

Any insights will be appreciated.


Show us a small, compilable example program which
exhibits the problem behavior, and perhaps we can
help.

-Mike

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.