CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002
    Posts
    1,417

    new fstream class

    I am starting to write my own Non-STL fstream class because it is not supported by the compiler I'm using ( eVC++ 3.0). I looked at STLPort, but it is just too complex for what I really need. I have all the basic functionality working -- e.g. read, write in both binary and text modes. Now I want to start adding some of the more sophicated stuff, like setw() and setfill(). But I'm stuck on how to imnplement them. For example:

    stream << setw(8) << setfill('*') << 123.45F << endl;

    Can anyone tell me how setw and setfill functions are implemented so that they return the stream object?

    Thanks

  2. #2
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    I think the best approach would be for you to look at a current
    implementation if you don't want to use a library that's already
    out there. So, look at STLPort's implementation of fstream and
    find out how THEY do it. If you have Visual Studio, see how they
    do it as well.

    The more you imitate these, however, the stronger the argument
    is for you to juse use STLPort [or some other library] to begin
    with.

    --Paul

  3. #3
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470
    Check out The C++ Programming Language by Bjarne Stroustrup. There's a whole section on how to write your own I/O manipulators (section 21.4.6.3).
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured