Empty the vector
//C++ STL program to demonstrate example of
//vector::empty() function
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v1;
//printing the size of the vector
cout << "Total number of elements: " << v1.size() << endl;
//checking whether vector is empty or not
if (v1.empty())
cout << "vector is empty." << endl;
else
cout << "vector is not empty." << endl;
//pushing elements
v1.push_back(10);
v1.push_back(20);
v1.push_back(30);
v1.push_back(40);
v1.push_back(50);
//printing the size of the vector
cout << "Total number of elements: " << v1.size() << endl;
//checking whether vector is empty or not
if (v1.empty())
cout << "vector is empty." << endl;
else
cout << "vector is not empty." << endl;
return 0;
}