#include#include using namespace std; int main() { vector v = {1, 2, 3, 4, 5}; int size = v.getSize(); cout << "The size of the vector is: " << size << endl; return 0; }
#includeThis code creates an empty vector and then uses the getSize() method to check if the vector is empty. The output will be "The vector is empty". Package/library: Standard Template Library (STL)#include using namespace std; int main() { vector v; if(v.getSize() == 0) { cout << "The vector is empty" << endl; } else { cout << "The vector is not empty" << endl; } return 0; }