Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > File cannot open with ofstream constructor !

Reply
Thread Tools

File cannot open with ofstream constructor !

 
 
tornado
Guest
Posts: n/a
 
      07-29-2003
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.
 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      07-29-2003

tornado <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A constructor calling another constructor (default constructor)? Generic Usenet Account C++ 10 11-28-2007 04:12 AM
ofstream * vs. ofstream Squid Seven C++ 5 07-14-2005 07:34 AM
ofstream open bit sam C++ 5 05-06-2005 11:39 AM
ofstream file error checks? steve C++ 2 08-20-2003 12:28 AM
The file 'bin\WebProj.dll' cannot be copied to the run directory. The requested operation cannot be performed on a file with a user-mapped section open. J Gao ASP .Net 0 07-28-2003 04:18 PM



Advertisments