Hi . I am new in c++ programming and I need some help to complete my assignment. I have no idea how to begin and what to do . Please somebody explain it to me and guide me . I am not asking for complete solution just some hint. Thanks for your help in advanced.
the head file stack.h describes the data type STACK as follows:
class STACK{
int *const elems;
const int max;
int top;
public:
STACK(int m);
STACK(const STACK&s);
virtual int size ( ) const;
virtual operator int ( ) const;
virtual int operator[ ] (int x) const;
virtual STACK& operator<<(int e);
virtual STACK& operator>>(int &e);
virtual STACK& operator=(const STACK&s);
virtual void print( ) const;
virtual ~STACK( );
};
Thanks for your answer. I will post the full assignment to see.Maybe I didnt explain it well.
1.Problem description
An integer stack is a LIFO (last in, first out) data type that serves as a collection of integer elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the last element that was added. The data type STACK can be implemented with a linear data structure by using an integer pointer which is allocated a piece of memory that can store at most max elements. The head file stack.h describes the data type STACK as follows:
class STACK{
int *const elems; //memory allocated to store elements
const int max; //maximum number of elements the stack can contain
int top; //top indicator or number of elements in current stack
public:
STACK(int m); //create a stack which can store at most m elements
STACK(const STACK &s); //deep-copy constructor of stack s
virtual int size ( ) const; //get maximum number max
virtual operator int ( ) const; //get top indicator top
virtual int operator[ ] (int x) const; //get element at location x in the stack
virtual STACK& operator<<(int e); //push e into the stack
virtual STACK& operator>>(int &e); //pop an element to e from the stack
virtual STACK& operator=(const STACK&s); //deep-copy assignment of stacks
virtual void print( ) const; //print out the stack
virtual ~STACK( ); //destroy the stack
};
Please create a project named st using “console wizard” of C++ builder 6.0 that includes three files: stack.cpp which is used to implement the functions defined in stack.h and stest.cpp which contains the main function which is used to test the operations on stack .