// Function to add item x to stack
void Stack::push(Gumball x)
{
if(!isfull()){
top++;
gumballs[top] = x;
return; }
elsereturn;
}
// Function to remove and return top item of stack
int Stack::pop()
{
int x;
if(!isempty()) {
x = gumballs[top];
top--;
return x; }
elsereturn x;
}
Your Stack.h does not know about the Gumball class so it's just assuming it's an int. You should put the Gumball class definition into a .h file, and have Stack.h and your main file #include it. Also, your array of gumballs member in the stack class should be an array of Gumballs, not ints.