Need to create a queue of structs

Hello, I need to create a dynamically allocated, growable, queue of structs. I just need a little help getting started. From there, I know I can finish it on my own.

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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

 struct ABC{

		string name;
		unsigned empNo;
		double salary;
	};

class Queue{

public:

    static const unsigned initSize = 4;

    Queue();
    Queue( const Queue & other );
    ~Queue();
    Queue & add( const ABC & abc );
    ABC remove();
    unsigned getSize() const;

    Queue & operator=( const Queue & rhs );

private:

    unsigned size;
    unsigned totalSize;
    unsigned front;
    unsigned back;

    ABC * ptr;
};

void die(const string & msg);

int main(){

    Queue q;

}

void die(const string & msg){

cerr << "Fatal error: " << msg << endl;
exit(EXIT_FAILURE);

}

Queue::Queue(){
    size = 0;
    back = 0;
    front = 0;

    totalSize = initSize;

    try{
    ptr = new ABC[totalSize];
    }
    catch(const bad_alloc){
    die("Alloc. failure");
    }

}

Queue::Queue(const Queue & other){}

Queue::~Queue(){}

Queue & Queue::add(const ABC & abc){}

ABC Queue::remove(){}

Queue & Queue::operator=( const Queue & rhs ){}

unsigned Queue::getSize() const {return size;}
Last edited on
Last edited on
Topic archived. No new replies allowed.