vector::empty
測試,如果向量是空的。
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