#pragma once
#include <iostream>
using namespace std;
class AStack {
private:
int maxSize;
int top;
int *listArray;
public:
AStack(int size) {
maxSize = size;
top = 0;
listArray = new int[maxSize];
}
~AStack() {
delete[] listArray;
}
void clear() {
top = 0;
}
void push(const int it) {
listArray[top++] = it;
}
int pop() {
return listArray[--top];
}
int topValue()const {
return listArray[top - 1];
}
int length()const {
return top;
}
};
转载于:https://my.oschina.net/u/3772904/blog/1615065