friend ostream &operator<<(ostream &os, const Stack &stack) { for (int i = 0; i <= stack.top; i++) { os << stack.stackArray[i]; if (i != stack.top) { os << ","; } } return os; }