Thread: about stack

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    about stack

    Hello,

    I am making a program on "stack" data structure and have used classes in them to make the C++ program.


    Is it necessary that we should put a return type for "isFull()" and "Isempty()" method?

    Also, are "IsFull" and "Isempty" member functions of stack?

    Regads,
    Last edited by student111; 11-18-2013 at 06:10 AM. Reason: correcting

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by student111
    Is it necessary that we should put a return type for "isFull()" and "Isempty()" method?
    You certainly should specify the return type, so I assume that you are asking if the return type should be something other than void.

    It sounds like they are functions that return a boolean value, so yes, I would expect a return type other than void. That said, it is still possible to have them have void as the return type, but it isn't what I would expect here.

    Quote Originally Posted by student111
    Also, are "IsFull" and "Isempty" member functions of stack?
    That depends on how you want to design the interface of the class. Depending on what is the core interface you provide, these functions do not necessarily have to be member functions.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack
    By *nick in forum Windows Programming
    Replies: 1
    Last Post: 09-17-2012, 01:05 PM
  2. Stack ADT
    By pablo9891 in forum C Programming
    Replies: 6
    Last Post: 06-15-2012, 09:25 AM
  3. top of stack
    By greatunknown in forum C Programming
    Replies: 3
    Last Post: 10-27-2009, 04:54 PM
  4. Stack
    By zonf in forum C Programming
    Replies: 12
    Last Post: 12-14-2005, 06:30 AM
  5. Using a stack
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 05-09-2002, 10:44 PM