void pushItem or int pushItem checking err codes

Posted on 2009-02-19
Last Modified: 2012-05-06

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

Something like this

print somethng....

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

which is the usual way. thanks a million.
Question by:zizi21
    LVL 10

    Assisted Solution

    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.
    LVL 53

    Accepted Solution

    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.

    Author Comment

    thanks a million...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
    This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now