如果该向量为空,测试。
bool empty( ) const;
返回值
true,如果该向量为空; false,如果该矢量不为空。
示例
// vector_empty.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>
int main( )
{
   using namespace std;   
   vector <int> v1;
   v1.push_back( 10 );
   if ( v1.empty( ) )
      cout << "The vector is empty." << endl;
   else
      cout << "The vector is not empty." << endl;
}
要求
标头: <vector>
命名空间: std