stack data structure c++

#include <iostream>
#include <stack>

int main() {
    std::stack<int> myStack;

    // Step 1: Push elements onto the stack
    myStack.push(5);
    myStack.push(10);
    myStack.push(15);

    // Step 2: Access the top element of the stack
    int topElement = myStack.top();

    // Step 3: Pop the top element from the stack
    myStack.pop();

    // Step 4: Check if the stack is empty
    bool isEmpty = myStack.empty();

    // Step 5: Get the size of the stack
    std::size_t stackSize = myStack.size();

    // Step 6: Print the elements of the stack
    while (!myStack.empty()) {
        std::cout << myStack.top() << " ";
        myStack.pop();
    }

    return 0;
}