Can someone check my work to make sure I did the following correct...

The array-based implementations of stacks in this section impose and upper limit on the max size that a stack may have. Write a member function full() for the stack class that returns true or false according to whether or not the array used to store the stack elements is full...

Here is my code...

bool checkinput(string input,int max,char stack[])
{char m=' ';
int n=0,i=0;
 while(i<input.size()&&m!='z')
   {if(input[i]=='{')
        push(stack,n,max,input[i]);
   else if(input[i]=='}')
        m=pop(stack,n);
    i++;
    }
if(m!='x'&&n==0)
    return true;
else
    return false;

This snippet seems much more 'C-ish' than 'C++-ish' since in C++ I would expect some code like:

class Stack {
  private:
  char[] stack_storage
  public:
  // constructor
  // destructor
  void push(item); // may throw
  char pop();
  /* for this assignment */
  bool full();
};

and your assignment would be to implement

bool Stack::full() {
 // something goes here
}

The way you implement method full() is going to depend quite a bit on how you implement push() and pop() (since you need to know where push puts the next item, or pop gets it). If you are thinking about how to code it easily, you might be tempted to push at stackData[0], but I recommend that you try to find a way to push and pop at the other end of the array, to avoid shifting all the data when you manipulate the stack.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.