#include#include int main() { std::stack myStack; myStack.push(1); myStack.push(2); myStack.push(3); std::cout << "Before pop(): " << myStack.top() << "\n"; myStack.pop(); std::cout << "After pop(): " << myStack.top() << "\n"; return 0; }
Before pop(): 3 After pop(): 2This example creates a stack of integers and adds three elements to it. The function `myStack.pop()` is then called, which removes the top element of the stack. Package Library: The std::stack::pop() function is part of the C++ standard library, which is included in the std namespace (`std::stack` and `std::cout` in the example). Therefore, no external package/library is required to use this function.