#include using namespace std; class stackN; class NodeS{ private: NodeS(int, Nod
ID: 3576696 • Letter: #
Question
#include
using namespace std;
class stackN;
class NodeS{
private:
NodeS(int, NodeS*);
int data;
NodeS* next;
friend class stackN;
friend ostream& operator<<(ostream&, const stackN&);
};
class stackN{
public:
stackN();
stackN(const stackN&);
~stackN();
stackN& operator=(const stackN&);
bool push(int);
bool pop();
int getTop();
bool empty() const;
bool full() const;
bool clear();
bool operator==(const stackN&) const;
friend ostream& operator<<(ostream&, const stackN&);
private:
NodeS* top;
};
queueA.h
#include
using namespace std;
class queueA{
public:
queueA(int = 10);
queueA(const queueA&);
~queueA();
queueA& operator=(const queueA&);
bool enqueue(int);
bool dequeue();
int getFront();
bool empty() const;
bool full() const;
bool clear();
bool operator==(const queueA&) const;
friend ostream& operator<<(ostream&, const queueA&);
private:
int max;
int front;
int rear;
int *data;
};
queueN.h
#include
using namespace std;
class queueN;
class NodeQ{
private:
NodeQ(int, NodeQ*);
int data;
NodeQ* next;
friend class queueN;
friend ostream& operator<<(ostream&, const queueN&);
};
class queueN{
public:
queueN();
queueN(const queueN&);
~queueN();
queueN& operator=(const queueN&);
bool enqueue(int);
bool dequeue();
int getFront();
bool empty() const;
bool full() const;
bool clear();
bool operator==(const queueN&) const;
friend ostream& operator<<(ostream&, const queueN&);
private:
NodeQ* front;
NodeQ* rear;
};
I just need the .cpp files of these header files.
Explanation / Answer
#include<iostream>
using namespace std;
class stackA
{
private:
int max;
int top;
int *data;
public:
stackA(int i=10);
stackA(const &stack)
{
stack->max = this.max;
stack->top = -1;
stack->data = (int*) malloc(stack->capacity * sizeof(int));
return stack;
}
~stack()
{
cout<<"Deallocating memory"
}
stackA& operator=(const stack&A);
bool push(int a)
{
if (StackA.full())
return false;
else
{
stackA->data[++stackA->top] = a;
return true;
}
}
bool pop();
int getTop();
bool empty() const;
{
if(stackA->top==-1)
return true;
else
return false;
}
bool full() const
{
if(stack->top == stackA->max - 1)
return true;
else return false;
}
bool clear();
bool operator==(const stackA&) const;
friend ostream& operator<<(ostream&,const stackA&);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.