Please HELP!!!!! i hope someone can help im really struggling with this.
----------------------------------
write a class WeirdIntStack that implements our stack ADT, but which is only allowed to use queues in the implementation. Your implementation is not allowed to use objects of any kind other than queues, and you are not allowed to use arrays. Integer-type variables are allowed.
The class should contain the following:
a default constructor
a copy constructor
a destructor
the methods getSize, isEmpty, push, pop and getTop that have the effect described in our ADT.
I also require that your implementation of pop and getTop run in
O(1)
time. I have no other requirements on the other methods, except that they should not be unnecessarily slow.
You should use the STL implementation of queues. Note that no assignment operator is implemented, so copies of queues must be made manually.
Hint: You should only need one queue in your class member variables, but some of your methods will require an additional queue as temporary storage.
------------------------------------
CPP file
----------------------------------
//
#include <cstdlib> //Used for NULL
#include <vector> //Try-Catch statement
#include "WeirdIntStack.h"
using namespace std;
}
//-------------------------------------------------------------------------
bool WeirdIntStack::Push(TYPE item) //Adding an item to the list (at the top)
{
if (IsFull() == false)
{
NodePtr n = new Node; //Adding a new link to the list
n->next = head; //Setting pointer to the front of the list
n->data = item; //Setting that new pointer's data
head = n; //Setting the head to the new beginning of the list
return true;
}
return false; //If failed to add item, something like it being full
}
void WeirdIntStack::Pop() {
//queue<int> myqueue
this.back()
// TYPE item; //Getting a new item of TYPE
// if (!IsEmpty()) {
// Delete = head; //Setting delete to the head of the stack
// Deleting the node
//
// } else if (head->next == NULL && head->data != NULL) {
// item = head->data;
// delete Delete;
// head = NULL;
// }
// return item;
}
//
-------------------------------------------------------------------------------
@OP: write a freaking damn question, ¿what do you need help with?
> You should use the STL implementation of queues
> You should only need one queue in your class member variables
perhaps you should read your assignment.