i recently asked a on a forum how to handle the problem if a user pushes onto a full stack or pops from an empty stack on how to handle this problem.....
my question is could anyone give a accurate example code of the first example he gave me below? i dont know how to ensure the user calls isFull or isEmpty before a call to push...i don't understand
Pushing to a fixed size stack with user responsibility:
User can only call Push if they've first called "IsFull" and got a return value of false. As long as the user does this, then Push can never fail.
Seeing as it's never meant to fail, simply add an assertion to check for failures.
Pushing to a fixed size stack without user responsibility:
Make push return a boolean value indicating success/failure.