basic_ofstream::is_open

指示文件是否处于打开状态。

bool is_open( ) const;

返回值

true,如果文件处于打开状态,否则 false。

备注

成员函数返回 rdbuf -> is_open

示例

// basic_ofstream_is_open.cpp
// compile with: /EHsc
#include <fstream>
#include <iostream>

int main( ) 
{
   using namespace std;
   ifstream file;
   // Open and close with a basic_filebuf
   file.rdbuf( )->open( "basic_ofstream_is_open.txt", ios::in );
   file.close( );
   if (file.is_open())
      cout << "it's open" << endl;
   else
      cout << "it's closed" << endl;
}

Output

it's closed

要求

标头: <fstream>

命名空间: std

请参见

参考

basic_ofstream Class

iostream编程

(mfc)约定