I’m talking about line 4 after public:
class Stack {
int top;
public:
int a[MAX]; // Maximum size of Stack
Stack() { top = -1; }
bool push(int x);
int pop();
int peek();
bool isEmpty();
};
bool Stack::push(int x)
{
if (top >= (MAX - 1)) {
cout << "Stack Overflow";
return false;
}
else {
a[++top] = x;
cout << x << " pushed into stack\n";
return true;
}
}
UPDATE: Because others have commented on it, I just wanted to clarify that I know what an array is and how to use one and I have read documentations before. I just needed help in understanding how it is used inside classes. Also, I would like to thank the people who helped me by answering the question. I appreciate it very much!