共用方式為


list::empty

測試,如果清單是空的。

bool empty( ) const;

傳回值

true ,如果清單是空的, false ,如果清單不是空的。

範例

// list_empty.cpp
// compile with: /EHsc
#include <list>
#include <iostream>

int main( )
{
   using namespace std;
   list <int> c1;

   c1.push_back( 10 );
   if ( c1.empty( ) )
      cout << "The list is empty." << endl;
   else
      cout << "The list is not empty." << endl;
}
  

需求

標題: <list>

命名空間: std

請參閱

參考

list Class

標準樣板程式庫