C++ Copy Constructor Queues Help!

Status
Not open for further replies.
I have been working on this program forever and I have to hand it in soon. Here is what I have gotten so far that is correct. I really don't know how to copy the queue. I know I have to use a for loop but I don't know how to access it. If anyone could help I would really appriciate it.

#include <stdlib.h>
//#include <stdlib.h>
#include <iostream.h>

class queue {

public:
// constructors and destructors
queue() //default constructor
{
frontptr = NULL;

backptr = NULL;
}
queue(const queue& aqueue) //copy constructor
{
}
~queue() //destructor
{
}

// queue operations:
void create_first_node()
{
frontptr = new Node;
frontptr->item = 2;
frontptr->next = NULL;
backptr = frontptr;

}
void create_remaining_nodes()
{
}
//private:
struct Node //a node on the queue
{
int item; //a data item on the queue
Node *next; //pointer to next node
}; // end struct


Node *frontptr; //pointer to front of queue
Node *backptr; //pointer to back of queue
Node *newptr; //pointer to new Node


}; //end class


void main()
{

queue Aqueue;
Aqueue.create_first_node();
cout <<"this is a test" << endl;



}



please I don't know what do I really need help
 
sorry for that. The program I have to write is this: I have to write a program that will copy a queue into another queue using the copy consturctor and then print it out and I am having problems doing that. If anyone could help I would greatly appriciate it. I know what to do in theory, but I don't know how to take what I know on how to do this and implement it into code. My teacher just like my book only show us the code in theory and they do not show us any examples. Here is the program:

Code:
#include <stdlib.h>
//#include <stdlib.h>
#include <iostream.h>

class queue {

	public:
		// constructors and destructors
		queue()					//default constructor
		{
			frontptr = NULL;
				
			backptr = NULL;
		}		
		queue(const queue& aqueue)	//copy constructor
			{
			}
		~queue()					//destructor
		{
		}

		// queue operations:
		void create_first_node()
		{
			frontptr = new Node;
			frontptr->item = 2;
			frontptr->next = NULL;
			backptr = frontptr;
			
		}
		void create_remaining_nodes()
		{
		}
	//private:
		struct Node					//a node on the queue
		{
			int		item;			//a data item on the queue
			Node	*next;			//pointer to next node
		}; // end struct


		Node	*frontptr;			//pointer to front of queue
		Node	*backptr;			//pointer to back of queue
		Node	*newptr;			//pointer to new Node


}; //end class


void main()
{

	queue Aqueue;
	Aqueue.create_first_node();
	cout <<"this is a test" << endl;
}
 
Status
Not open for further replies.