I am trying to implement a queue using two stacks so I have already made a fully functioning class stack. When creating the queue header file, I included the stack header file. And then I included queue.h in my queue.cpp file. However, when I was writing my enqueue function, which uses a stack object, the stack object wasn't visible and I don't know why. What am I doing wrong?
stack.h
using namespace std;
class stack
{
public:
stack(); //constructor
~stack();//deconstructor
void push(int); //puts int on the stack
void pop(); //removes int off the stack
void printStack();
private:
struct Node
{
int number;
Node* prev;
};
Node* top;
void readNode(Node* r);
};
queue.h
#include "stack.h"
class queue
{
public:
queue();
virtual ~queue();
void enqueue(int item);
void dequeue();
bool isEmpty() const;
private:
stack s1;
stack s2;
};
queue.cpp
#include "queue.h"
void enqueue(int item)
{
s1.push(item);
}