Using a reference in a conditional statement...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • barcaroller

    Using a reference in a conditional statement...

    I was looking at some code that uses fstream:


    #include <fstream>
    //
    // which includes:
    // istream& getline( char* buffer, streamsize num );
    //

    ifstream fin;
    while( fin.getline(lin e, size) ) {
    ...
    }


    If fin.getline() returns a reference, how could it be used in a conditional
    statement? I've looked at the member functions and I could not find a
    conversion to a bool type.



  • Jerry Coffin

    #2
    Re: Using a reference in a conditional statement...

    In article <frgqne$blm$1@a ioe.org>, barcaroller@mus ic.net says...

    [ ... ]
    If fin.getline() returns a reference, how could it be used in a conditional
    statement? I've looked at the member functions and I could not find a
    conversion to a bool type.
    The fact that it's a reference is irrelevant here -- what's being
    evaluated is the object referred to by the reference. Rather than a
    conversion to bool, what's being used here is the conversion to void *.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.

    Comment

    Working...