// StackPractice.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
class ArrayStack{
private:
int*arr;
int n=0;
int location=0;
public:
void InitArr(int n) {
this->arr = new int[n];
this->n = n;
}
bool push(int x) {
if (this->location == n) {
return false;
}
arr[this->location] = x;
this->location++;
return true;
}
int pop() {
if (this->location == 0) {
return NULL;
}
int value = arr[this->location-1];
this->location--;
return value;
}
};
int main()
{
ArrayStack a;
a.InitArr(20);
a.push(1);
int temp = a.pop();
int temp2 = a.pop();
return 0;
}