Implementing isempty function on a QueueAsAStack that privately inherits a LinkedStack
up vote
-2
down vote
favorite
For this project, we need to create a queue that is a Linked Stack. I am having trouble implementing the isEmpty function for this queue.
QueueAsAStack.h
#ifndef QUEUE_AS_A_STACK
#define QUEUE_AS_A_STACK
#include "QueueInterface.h"
#include "LinkedStack.cpp"
template<class ItemType>
class QueueAsAStack : public QueueInterface <ItemType>, private LinkedStack <ItemType> {
public:
bool isEmpty() const;
bool enqueue(const ItemType&);
bool dequeue();
ItemType peekFront() const;
};
#endif
QueueAsAStack.cpp
//Function to check if the Queue is empty
template<class ItemType>
bool QueueAsAStack<ItemType>::isEmpty() const {
return stack->peek() == 0;
}
Any Advice would be appreciated.
c++
add a comment |
up vote
-2
down vote
favorite
For this project, we need to create a queue that is a Linked Stack. I am having trouble implementing the isEmpty function for this queue.
QueueAsAStack.h
#ifndef QUEUE_AS_A_STACK
#define QUEUE_AS_A_STACK
#include "QueueInterface.h"
#include "LinkedStack.cpp"
template<class ItemType>
class QueueAsAStack : public QueueInterface <ItemType>, private LinkedStack <ItemType> {
public:
bool isEmpty() const;
bool enqueue(const ItemType&);
bool dequeue();
ItemType peekFront() const;
};
#endif
QueueAsAStack.cpp
//Function to check if the Queue is empty
template<class ItemType>
bool QueueAsAStack<ItemType>::isEmpty() const {
return stack->peek() == 0;
}
Any Advice would be appreciated.
c++
1
Hey, welcome to Stack Overflow :) Could you please tell us what "having trouble" means? When asking "why isn't this working" or similar questions, it's good to include: 1.) your code (which you have, great :)) 2.) what you want the code to do, exactly, and 3.) what you've tried so far, and how it has not met the requirements of 2.)
– MyStackRunnethOver
Nov 20 at 1:39
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
For this project, we need to create a queue that is a Linked Stack. I am having trouble implementing the isEmpty function for this queue.
QueueAsAStack.h
#ifndef QUEUE_AS_A_STACK
#define QUEUE_AS_A_STACK
#include "QueueInterface.h"
#include "LinkedStack.cpp"
template<class ItemType>
class QueueAsAStack : public QueueInterface <ItemType>, private LinkedStack <ItemType> {
public:
bool isEmpty() const;
bool enqueue(const ItemType&);
bool dequeue();
ItemType peekFront() const;
};
#endif
QueueAsAStack.cpp
//Function to check if the Queue is empty
template<class ItemType>
bool QueueAsAStack<ItemType>::isEmpty() const {
return stack->peek() == 0;
}
Any Advice would be appreciated.
c++
For this project, we need to create a queue that is a Linked Stack. I am having trouble implementing the isEmpty function for this queue.
QueueAsAStack.h
#ifndef QUEUE_AS_A_STACK
#define QUEUE_AS_A_STACK
#include "QueueInterface.h"
#include "LinkedStack.cpp"
template<class ItemType>
class QueueAsAStack : public QueueInterface <ItemType>, private LinkedStack <ItemType> {
public:
bool isEmpty() const;
bool enqueue(const ItemType&);
bool dequeue();
ItemType peekFront() const;
};
#endif
QueueAsAStack.cpp
//Function to check if the Queue is empty
template<class ItemType>
bool QueueAsAStack<ItemType>::isEmpty() const {
return stack->peek() == 0;
}
Any Advice would be appreciated.
c++
c++
asked Nov 20 at 1:21
Dillon Twining
11
11
1
Hey, welcome to Stack Overflow :) Could you please tell us what "having trouble" means? When asking "why isn't this working" or similar questions, it's good to include: 1.) your code (which you have, great :)) 2.) what you want the code to do, exactly, and 3.) what you've tried so far, and how it has not met the requirements of 2.)
– MyStackRunnethOver
Nov 20 at 1:39
add a comment |
1
Hey, welcome to Stack Overflow :) Could you please tell us what "having trouble" means? When asking "why isn't this working" or similar questions, it's good to include: 1.) your code (which you have, great :)) 2.) what you want the code to do, exactly, and 3.) what you've tried so far, and how it has not met the requirements of 2.)
– MyStackRunnethOver
Nov 20 at 1:39
1
1
Hey, welcome to Stack Overflow :) Could you please tell us what "having trouble" means? When asking "why isn't this working" or similar questions, it's good to include: 1.) your code (which you have, great :)) 2.) what you want the code to do, exactly, and 3.) what you've tried so far, and how it has not met the requirements of 2.)
– MyStackRunnethOver
Nov 20 at 1:39
Hey, welcome to Stack Overflow :) Could you please tell us what "having trouble" means? When asking "why isn't this working" or similar questions, it's good to include: 1.) your code (which you have, great :)) 2.) what you want the code to do, exactly, and 3.) what you've tried so far, and how it has not met the requirements of 2.)
– MyStackRunnethOver
Nov 20 at 1:39
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
I think we are in the same class. If you get anywhere let me know. For isEmpty we used the linked stack's isEmpty method as follows, "return LinkedStack::isEmpty();", inside the isEmpty method for QueueAsAStack.
Yes I ended up changing that, now I just need to figure out the peekFront implementation and hopefully it will work.
– Dillon Twining
Nov 20 at 23:40
@DillonTwining currently we are trying to figure out how to get the priority queue class working with the enqueue in queue class since that enqueue is pushing in from the bottom of the stack when the priority queue needs pushed in from the top.
– Kaoteni
Nov 20 at 23:43
add a comment |
up vote
0
down vote
think I'm in the same class, did you guys figure the project itself out, yet? I cannot for the life of me figure out the second part.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I think we are in the same class. If you get anywhere let me know. For isEmpty we used the linked stack's isEmpty method as follows, "return LinkedStack::isEmpty();", inside the isEmpty method for QueueAsAStack.
Yes I ended up changing that, now I just need to figure out the peekFront implementation and hopefully it will work.
– Dillon Twining
Nov 20 at 23:40
@DillonTwining currently we are trying to figure out how to get the priority queue class working with the enqueue in queue class since that enqueue is pushing in from the bottom of the stack when the priority queue needs pushed in from the top.
– Kaoteni
Nov 20 at 23:43
add a comment |
up vote
0
down vote
I think we are in the same class. If you get anywhere let me know. For isEmpty we used the linked stack's isEmpty method as follows, "return LinkedStack::isEmpty();", inside the isEmpty method for QueueAsAStack.
Yes I ended up changing that, now I just need to figure out the peekFront implementation and hopefully it will work.
– Dillon Twining
Nov 20 at 23:40
@DillonTwining currently we are trying to figure out how to get the priority queue class working with the enqueue in queue class since that enqueue is pushing in from the bottom of the stack when the priority queue needs pushed in from the top.
– Kaoteni
Nov 20 at 23:43
add a comment |
up vote
0
down vote
up vote
0
down vote
I think we are in the same class. If you get anywhere let me know. For isEmpty we used the linked stack's isEmpty method as follows, "return LinkedStack::isEmpty();", inside the isEmpty method for QueueAsAStack.
I think we are in the same class. If you get anywhere let me know. For isEmpty we used the linked stack's isEmpty method as follows, "return LinkedStack::isEmpty();", inside the isEmpty method for QueueAsAStack.
answered Nov 20 at 23:23
Kaoteni
176
176
Yes I ended up changing that, now I just need to figure out the peekFront implementation and hopefully it will work.
– Dillon Twining
Nov 20 at 23:40
@DillonTwining currently we are trying to figure out how to get the priority queue class working with the enqueue in queue class since that enqueue is pushing in from the bottom of the stack when the priority queue needs pushed in from the top.
– Kaoteni
Nov 20 at 23:43
add a comment |
Yes I ended up changing that, now I just need to figure out the peekFront implementation and hopefully it will work.
– Dillon Twining
Nov 20 at 23:40
@DillonTwining currently we are trying to figure out how to get the priority queue class working with the enqueue in queue class since that enqueue is pushing in from the bottom of the stack when the priority queue needs pushed in from the top.
– Kaoteni
Nov 20 at 23:43
Yes I ended up changing that, now I just need to figure out the peekFront implementation and hopefully it will work.
– Dillon Twining
Nov 20 at 23:40
Yes I ended up changing that, now I just need to figure out the peekFront implementation and hopefully it will work.
– Dillon Twining
Nov 20 at 23:40
@DillonTwining currently we are trying to figure out how to get the priority queue class working with the enqueue in queue class since that enqueue is pushing in from the bottom of the stack when the priority queue needs pushed in from the top.
– Kaoteni
Nov 20 at 23:43
@DillonTwining currently we are trying to figure out how to get the priority queue class working with the enqueue in queue class since that enqueue is pushing in from the bottom of the stack when the priority queue needs pushed in from the top.
– Kaoteni
Nov 20 at 23:43
add a comment |
up vote
0
down vote
think I'm in the same class, did you guys figure the project itself out, yet? I cannot for the life of me figure out the second part.
add a comment |
up vote
0
down vote
think I'm in the same class, did you guys figure the project itself out, yet? I cannot for the life of me figure out the second part.
add a comment |
up vote
0
down vote
up vote
0
down vote
think I'm in the same class, did you guys figure the project itself out, yet? I cannot for the life of me figure out the second part.
think I'm in the same class, did you guys figure the project itself out, yet? I cannot for the life of me figure out the second part.
answered Nov 21 at 3:44
Bahak
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384915%2fimplementing-isempty-function-on-a-queueasastack-that-privately-inherits-a-linke%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Hey, welcome to Stack Overflow :) Could you please tell us what "having trouble" means? When asking "why isn't this working" or similar questions, it's good to include: 1.) your code (which you have, great :)) 2.) what you want the code to do, exactly, and 3.) what you've tried so far, and how it has not met the requirements of 2.)
– MyStackRunnethOver
Nov 20 at 1:39