简单数据结构之 vector 栈(C++ vector 实现)

/*
 ============================================================================
 Name        : stack_array.cpp
 Author      : ntsk13 [email protected]
 Version     :
 Copyright   : GPL
 Description : stack array study, complement by C++
 Date        : 2015.06.17
 ============================================================================
 */

#include 
#include 
using namespace std;

#define STACK_CAPACITY 10
typedef struct {
	int data;
}Elem_t;

class  stack {
public:
	vector v;
	int top;
	int capacity;
	int cur_len;

	void init();
	void clear();
	bool is_empty();
	Elem_t get_top_elem();
	bool push(Elem_t e);
	bool pop(Elem_t &e);
	int get_len();
	void traverse();
};

int main(void) {
	stack S;
	Elem_t zero,one,two,three,four,five,six;
	zero.data=0;
	one.data=1;
	two.data=2;
	three.data=3;
	four.data=4;

	S.init();
	cout<<"S is empty ? "<<( (S.is_empty()) ?"Yes":"No")<

你可能感兴趣的:(步步为营学算法)