#includeIn this example, we create a stack of integers and add three elements to it using the push() method. Then we use the top() method to retrieve the top element, which in this case is 3. This code uses the C++ Standard Library's stack package. Overall, the stack is a useful data structure in C++ for keeping track of elements in a last-in-first-out order. The use of the top() method helps to easily access the most recently added item in the stack.#include using namespace std; int main() { stack myStack; myStack.push(1); myStack.push(2); myStack.push(3); cout << "Top of the stack: " << myStack.top() << endl; return 0; }