GitHub Viewer
#include
#include
#include
//template
class Stack{
//data member abstraction
private:
int capacity;
int size;
int* array;
//constructor
public:
Stack(){
this->size = 0;
this->capacity = 1;
this->array = new int[capacity];
}
Stack(int capacity){
this->capacity = capacity;
this->array = new int[capacity];
int size = 0;
}
~Stack(){
delete[] array;
}
public:
//getter is_full
int get_size(){
return this->size;
}
int get_capacity(){
return this->capacity;
}
bool is_full(){
if(size == capacity){
return true;
}
return false;
}
int top(){
return this->array[size - 1];
}
//getter
bool is_empty(){
if(size == 0){
return true;
}
return false;
}
//setter push
void push(int data){
if(size == capacity){
std::cout