Templates - Stack

STL stack, there may be some unwanted information.
In fact, this is achieved with an array of after ghosts. Feeling not as directly.

struct Stack{
    int st[MAXSIZE];
    int top;
    inline void Clear(){
        top=0;
    }
    inline void Push(int x){
        st[++top]=x;
    }
    inline void Pop(){
        --top;
    }
    inline int Top(){
        return st[top];
    }
    inline int Size(){
        return top;
    }
    inline bool Empty(){
        return !top;
    }
};

Guess you like

Origin www.cnblogs.com/Yinku/p/11210635.html