/*
============================================================================
Name : stack_array.cpp
Author : ntsk13 beijiwei@qq.com
Version :
Copyright : GPL
Description : stack array study, complement by C++
Date : 2015.06.17
============================================================================
*/
#include <iostream>
#include <vector>
using namespace std;
#define STACK_CAPACITY 10
typedef struct {
int data;
}Elem_t;
class stack {
public:
vector<Elem_t> 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")<<endl;
S.pop(six);
简单数据结构之 vector 栈(C++ vector 实现)
最新推荐文章于 2024-03-12 18:06:45 发布
