Using C need help implementing the following functions Imple

Using C++, need help implementing the following functions

Implement the Stack ADT using ARRAY – based approach

In each of the operations, there are comments within /*   */ or // which states what each operation is looking for and some of the implementations has already been started/done. Need help with finishing the rest of the implementation for each of the following operations below. Thank you.

----------------------------------------------------------------------------------------------------------

#include \"StackArray.h\"

template <typename DataType>

StackArray<DataType>::StackArray(int maxNumber)

{

      

       //Implement the constructor

       //creates an empty stack

       //allocates enough memory for a stack containing

       //maxNumber data items(if necessary)

}

template <typename DataType>

StackArray<DataType>::StackArray(const StackArray& other)

{

       //Implement the copy constructor

       //Initializes the stack to be equivalent to the other stack object parameter

}

template <typename DataType>

StackArray<DataType>& StackArray<DataType>::operator=(const StackArray& other)

{

       //overloaded assignment operator

       //sets the stack to be equivalent to the other stack object parameter

       //and returns to be the modified stack

}

//destructor

template <typename DataType>

StackArray<DataType>::~StackArray()

{

       //deallocates-frees memory

       delete[] this->dataItems;

}

//push

template <typename DataType>

void StackArray<DataType>::push(const DataType& newDataItem) throw (logic_error)

{

       //removes the most recently added (top) data item from the stack

       //and returns the value of the deleted item

}

template <typename DataType>

DataType StackArray<DataType>::pop() throw (logic_error)

{

       //implement the pop using array approach

}

//removes all data items in the stack

template <typename DataType>

void StackArray<DataType>::clear()

{

       this->top = 0;

      

       for (int i = 0; i < (this->maxSize - 1); i++)

       {

      

              this->dataItems[i] = 0;

       }

}

//checks if stack is empty

template <typename DataType>

bool StackArray<DataType>::isEmpty() const

{

       //returns true if the stack is empty

      

}

template <typename DataType>

bool StackArray<DataType>::isFull() const

{

       //returns true if the stack is full

}

Solution

#include \"StackArray.h\"

template <typename DataType>

StackArray<DataType>::StackArray(int maxNumber)

{

      

       //Implement the constructor

       //creates an empty stack

       //allocates enough memory for a stack containing

       //maxNumber data items(if necessary)

}

template <typename DataType>

StackArray<DataType>::StackArray(const StackArray& other)

{

       //Implement the copy constructor

       //Initializes the stack to be equivalent to the other stack object parameter

}

template <typename DataType>

StackArray<DataType>& StackArray<DataType>::operator=(const StackArray& other)

{

       //overloaded assignment operator

       //sets the stack to be equivalent to the other stack object parameter

       //and returns to be the modified stack

}

//destructor

template <typename DataType>

StackArray<DataType>::~StackArray()

{

       //deallocates-frees memory

       delete[] this->dataItems;

}

//push

template <typename DataType>

void StackArray<DataType>::push(const DataType& newDataItem) throw (logic_error)

{

       //removes the most recently added (top) data item from the stack

       //and returns the value of the deleted item

}

template <typename DataType>

DataType StackArray<DataType>::pop() throw (logic_error)

{

       //implement the pop using array approach

}

//removes all data items in the stack

template <typename DataType>

void StackArray<DataType>::clear()

{

       this->top = 0;

      

       for (int i = 0; i < (this->maxSize - 1); i++)

       {

      

              this->dataItems[i] = 0;

       }

}

//checks if stack is empty

template <typename DataType>

bool StackArray<DataType>::isEmpty() const

{

       //returns true if the stack is empty

      

}

template <typename DataType>

bool StackArray<DataType>::isFull() const

{

       //returns true if the stack is full

}

Using C++, need help implementing the following functions Implement the Stack ADT using ARRAY – based approach In each of the operations, there are comments wit
Using C++, need help implementing the following functions Implement the Stack ADT using ARRAY – based approach In each of the operations, there are comments wit
Using C++, need help implementing the following functions Implement the Stack ADT using ARRAY – based approach In each of the operations, there are comments wit
Using C++, need help implementing the following functions Implement the Stack ADT using ARRAY – based approach In each of the operations, there are comments wit
Using C++, need help implementing the following functions Implement the Stack ADT using ARRAY – based approach In each of the operations, there are comments wit

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site