• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

void pushItem or int pushItem checking err codes

hi,

is it usually to check whether the push operation in the stack is successful.

Something like this

if(pushItem()==SUCCESSFUL)
;
else
print somethng....

usually, i notice, it is void pushItem instead of int pushItem...

which is the usual way. thanks a million.
0
zizi21
Asked:
zizi21
2 Solutions
 
peetmCommented:
I would say that if pushItem() may fail [and it probably can!], then, you should have some mechanism for detecting that.

Of course, this could be implemented within pushItem(), but what would that mean - 'abort' most likely.

If you were using C++ you could use exceptions - functions that return indications of success/failure have a way of being called like subroutines, i.e., having their result ignored.
0
 
Infinity08Commented:
Depends. If your stack/queue has a limited size, you might want to return an error in case the stack is full, and the user tries to push a value on it.
0
 
zizi21Author Commented:
thanks a million...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now