ios::operator void *
operator void * ( ) const;

Convert stream to pointer.
  A stream derived from ios can be casted to a pointer. This pointer is null if any of the error flags failbit or badbit is set. Otherwise a non-zero pointer (not intended to be referenced - just to indicate success) is returned.



Return Value.
  0 if failbit or badbit is set.
  non-zero otherwise.


// ios, casting to pointer
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ifstream is; ("test.txt");
  if ( (void*)is == 0)
    cerr << "Error opening 'test.txt'\n";
  return 0;

Basic template member declaration ( basic_ios<charT,traits> ):
operator void * () const;

See also.
  fail, operator!
  ios class

© The C++ Resources Network, 2001