#include#include int main() { std::vector nums; nums.push_back(1); std::cout << "The vector contains: "; for(auto num : nums) { std::cout << num << " "; } std::cout << std::endl; return 0; }
#includeIn this example, we create an empty vector `nums` and add the integers 1, 2, and 3 to it using the `push_back` function. Package library: The `push_back` function is a member function of the `std::vector` class, which is part of the C++ Standard Library.#include int main() { std::vector nums; nums.push_back(1); nums.push_back(2); nums.push_back(3); std::cout << "The vector contains: "; for(auto num : nums) { std::cout << num << " "; } std::cout << std::endl; return 0; }