I have an assignment where i need to implement a stack and a queue with a link list. How would i go about implementing it? would i use a circular link list and i can add to the head and tail? I wasnt looking for any code handouts and i dont think its fair that i got minus two points for asking a generalized question. This is how i think it should be done:
#pragma once
#include <ostream>
using namespace std;
class quack
{
public:
quack(int capacity);
~quack(void);
bool pushFront(const int n); // push an item onto the front
bool pushBack(const int n); // push an item onto the back
bool popFront(int& n); // pop an item off the front
bool popBack(int& n); // pop an item off the back
int itemCount(void); // return the current number of stored items
private:
int front;
int back;
int maxsize;
int count;
struct Node
{
Nutricalc Data; // class wrapper?
Node* next;
};
public:
friend ostream& operator<<(ostream& out, quack& q);
friend ostream& operator<<(ostream& out, quack::item& i);
};