#include#include int main() { std::vector myVector = {1, 2, 3}; if (myVector.empty()) { std::cout << "Vector is empty" << std::endl; } else { std::cout << "Vector is not empty" << std::endl; } return 0; }
#includeIn this example, we create a Vector with three elements and then clear all the elements of the Vector using the "clear" function. Then we check if the Vector is empty or not using the "empty" function. Package library: The Vector is a part of the Standard Template Library (STL) in C++. Therefore, it is included in the C++ Standard Library and does not require any additional package library to be installed.#include int main() { std::vector myVector = {1, 2, 3}; myVector.clear(); if (myVector.empty()) { std::cout << "Vector is empty" << std::endl; } else { std::cout << "Vector is not empty" << std::endl; } return 0; }