#include#include int main() { std::vector numbers = {1, 2, 3, 4, 5}; auto it = numbers.begin(); std::cout << "First element of vector = " << *it << std::endl; return 0; }
#include#include int main() { std::string message = "Hello world!"; auto it = message.begin(); std::cout << "First character of string = " << *it << std::endl; return 0; }
#includeIn this example, we create a map that associates characters with their counts and use `begin()` to obtain an iterator pointing to the first key-value pair. We then use `it->first` and `it->second` to get the key and value of the first pair and print them to the console. Package/Library: Standard Template Library (STL)