qs regarding fstream

This is a discussion on qs regarding fstream within the C++ Programming forums, part of the General Programming Boards category; I have two quick questions I was hoping someone could answer. 1) what's the puropse on the ()'s in fin.close() ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    20

    qs regarding fstream

    I have two quick questions I was hoping someone could answer.

    1) what's the puropse on the ()'s in fin.close() or, as I just saw, cin.fail()? When I tried them without I get "member funciton must be called or address taken from main()".

    2) what does ios (as in ios::in) stand for and how do you pronounce it? Is it only used with fstreams?
    Self Learner--patience required

  2. #2
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    1. Because you're calling member functions. Just like:

    Code:
    void MyFunc(void) {  cout << "Whee\n"; }
    
    int main()
    {
       MyFunc(); // need () even though no arguments
       return (0);
    }
    
    /* */
    
    class MyClass {
    public:
       void MyFunc(void)  { cout << "Whee\n"; } 
    };
    
    int main()
    {
      MyClass Obj;
      Obj.MyFunc();
      return(0);
    }

    and 2. ios is the class that iostream, ostream, and istream are derived from, I believe.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    20
    makes sense . . . thanks
    Self Learner--patience required

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with fstream, one variabile for write and read
    By Smjert in forum C++ Programming
    Replies: 3
    Last Post: 02-03-2009, 09:19 PM
  2. Fstream. I/O
    By kevinawad in forum C++ Programming
    Replies: 2
    Last Post: 07-07-2008, 09:19 AM
  3. ARGH! fstream errors
    By OttoDestruct in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2004, 10:37 PM
  4. Are fstream and ofstream incompatible?
    By johnnyd in forum C++ Programming
    Replies: 5
    Last Post: 03-19-2003, 11:21 AM
  5. Problems with fstreams.
    By mosdef in forum C++ Programming
    Replies: 7
    Last Post: 06-19-2002, 03:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21