I need to create a copy constructor and an assignment operator for my class Queue, but I am a bit confused on how to go about it (I should also probably build a destructor to follow the rule of three).
I built my queue using another class "list" which is a linked list. Should I be building them using similar functions in my class "list" (like should I have a destructor, assignment operator and a copy constructor in my class "list" and call them in my class queue)? Or, can I build them directly using my class "queue"?
Below is my class "queue"
class Queue {
private:
List list;
public:
Queue (){
// I may need a default constructor
}
Queue(const Queue &other){
/* copy constructor. This and the assignment operator are only things I am currently
concerned with, but I probably should do the rest to follow the rule of three */
}
~Queue(){
// destructor
}
Queue operator= ( const Queue &other){
// Assignment Operator.
}
// I have these working
void push(Item);
void pop();
Item & peek();
bool empty();
};
Any help would be much appreciated