#include #include #include "Stack.h" #define STACKSIZE 3 #define INIT -1 using namespace std; Stack::Stack() { totalSize = STACKSIZE; top = INIT; array = (int*)malloc(sizeof(int)*totalSize); if(array == NULL) { printf("Memory not allocated\n"); abort(); } } void Stack::push(int element) { if(top == totalSize - 1) { totalSize *= 2; int *temp = (int*)realloc(array, sizeof(int)*totalSize); if(temp == NULL) { cout<<"Realloc failed"< #include #include #include "Stack.h" #include "Stack.cpp" #define STACKSIZE 3 using namespace std; int main(int argc, char const *argv[]) { Stack newStack; newStack.push(5); newStack.push(3); newStack.push(15); newStack.getTotatSize(); newStack.push(35); newStack.push(45); newStack.getTotatSize(); cout << newStack.pop() << endl; return 0; }