#include#include int main() { std::deque d{1, 2, 3, 4, 5}; std::cout << "The front element of deque d is: " << d.front() << '\n'; return 0; }
The front element of deque d is: 1
#include#include int main() { std::deque d{1, 2, 3, 4, 5}; std::cout << "The front element of deque d is: " << d.front() << '\n'; d.front() = 10; std::cout << "After modifying, the front element of deque d is: " << d.front() << '\n'; return 0; }
The front element of deque d is: 1 After modifying, the front element of deque d is: 10Both of these examples use the `front()` function provided by the C++ standard library. This function returns a reference to the first element of the deque. If the deque is empty, calling `front()` causes undefined behavior. The package library for `std::deque` is the C++ standard library, which provides containers, algorithms, and other utilities for C++ programming language.