hello, ive been set the task to implement a data structure of either a stack or as a queue. by what i know roughly (as i'm very inexperienced and new to this) is that a stack will be easier to do. i just a couple of questions.
what could i put through the stack? as what i know it adds and takes something from the top, but what?
What would be easier to implement?
Any heads up advice before i make it, and any barebones programmes i can base my stack on ?
struct int_stack
{
std::size_t size() const ; // current size
bool empty() const { return size() == 0 ; }
std::size_t capacity() const // maximum size to which the stack can grow
{ return MAX_SIZE ; }
int_stack() ; // default constructor
// push value into the stack if stack is not full, return true
// do nothing and return false if stack is full ie. size() == capacity()
bool push( int value ) ;
int top() const ; // invariant: not empty
void pop() ; // invariant: not empty
private:
staticconstexpr std::size_t MAX_SIZE = 1024 ;
// TODO: ...
};
intergers of what though? i'm being told in every direction to put numbers through it, but it seems to simple a programme just to have someone input a number to then be told the stack is full . . .
i have gained more insight to the world of stacks and queue! JLBorges, thanks you helped towards this! if anyone else can clear up a few things, do you always have to include classes?
whats with the public and private i keep seeing on everyones tutorial?
and whats with the -1 everyone keeps using too :),