how do you add items to a queue?

heres what I have so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template <class ItemType>
void QueType<ItemType>::Enqueue(ItemType newItem)
// Adds newItem to the rear of the queue.
{
    NodeType<ItemType>* newNode;

    newNode = new NodeType<ItemType>;
    newNode->info = newItem;
    newNode->next = NULL;
    if (qRear == NULL)
        qFront = newNode;
    else
        qRear->next = newNode;
    qRear = newNode;
}

I have the class for the queue and it builds fine but i dont know how to add numbers to the queue. in main i have this(these are only code snippets there is way more code in the program):
1
2
3
//Add data to the input end of the queue
					
void Enqueue(ItemType newItem);


can someone please help?
1
2
QueType<int> q;
q.Enqueue(100); // add 100 to the queue 
ok thanks but i want to be able to enter loads of numbers into the queue not just 100. so i would put
cout << "Enter numbers";
I don't know how to then put those numbers into the queue
can anyone help?
1
2
3
4
5
6
7
QueType<int> q;
int num;
std::cout << "Enter numbers" << std::endl;
for (std::cin >> num)
{
	q.Enqueue(num);
}

This will numbers from the user and insert them into the queue until EOF.
Topic archived. No new replies allowed.