klips/plates/cpp-datastruct/include/lib-datastruct.h

29 lines
476 B
C
Raw Normal View History

#ifndef LDS_H
#define LDS_H
#include <iostream>
2020-03-23 12:42:02 +00:00
class StackArray {
public:
2020-03-23 12:42:02 +00:00
StackArray() : top(EMPTY) {};
void Push(char val);
char Pop();
char Top() const;
void Display() const;
2020-03-23 12:42:02 +00:00
bool isEmpty() const;
private:
2020-03-23 12:42:02 +00:00
enum { EMPTY=-1, MAX=10 };
2020-03-23 12:46:49 +00:00
class Node {
2020-03-23 12:42:02 +00:00
public:
2020-03-23 12:46:49 +00:00
Node() : next(NULL) {};
Node(char val) : data(val), next(NULL) {};
2020-03-23 12:42:02 +00:00
char data;
2020-03-23 12:46:49 +00:00
Node* next;
2020-03-23 12:42:02 +00:00
};
2020-03-23 12:46:49 +00:00
Node stack[MAX];
2020-03-23 12:42:02 +00:00
int top;
};
#endif