Creating a Queue as a Dynamic Array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>

using namespace std;

void addElem(int num);
void delElem();

int num;
int main()
{
	
	char ans;
	cout << "Begin Queue Operation" << endl;
	cout << "******************************" << endl << endl;
	cout << "Do you wish to add an Element to the Queue?: ";
	cin >> ans;

	if(ans == 'Y' || 'y')
	{
		cout << "Enter the integer to store in the Queue:" << endl;
		cin >> num;
		addElem(num);

	}
	else
	{
		cout << "Then you wish to delete an Element from the Queue!" << endl;
		delElem();
	}
	

	return 0;
}

int *currentArray = 0;
int *tempArray = 0;
int index, oldSize, newSize;

void addElem(int num)
{
	currentArray = new int[oldSize];
	tempArray = new int[newSize];

	for(index = 0; index < oldSize; index++)
	{
		tempArray[index] = currentArray[index];
	}
	
	delete[] currentArray;
	currentArray = tempArray;
	tempArray = 0;
}

void delElem()
{
	currentArray = new int[oldSize];
	tempArray = new int[newSize];

	for(index = 0; index < oldSize; index++)
	{
		tempArray[index] = currentArray[index + 1];
	}

	delete[] currentArray;
	currentArray = tempArray;
	tempArray = 0;
}


I have generated an array for the Queue. I just need help implementing a Queue into this code. Can anyone help me?
use the STL queue's range constructor:
queue<int> q(currentarray, currentarray+newsize)
Oh, okay thanks.
Topic archived. No new replies allowed.