Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Charstack.h"
- #include <iostream>
- using namespace std;
- Charstack::Charstack() {
- stack_size = 0;
- }
- bool Charstack::empty() {
- return stack_size == 0;
- }
- void Charstack::push (StackElement_c item) {
- if(stack_size == CAPACITY)
- cout << "Stack is full!\n";
- else {
- stackArray[stack_size] = item;
- stack_size++;
- }
- }
- StackElement_c Charstack::pop() {
- stack_size--;
- if(stack_size >= 0)
- return stackArray[stack_size];
- else
- return '\0';
- }
- void Charstack::display() {
- for(int i = stack_size - 1; i >= 0; i--)
- cout << stackArray[i] << " ";
- }
Add Comment
Please, Sign In to add comment