How to initialize a Queue (linked list) and insert an element?

I have an assignment where I have to create a linked list and add and remove items from it. I'm having a problem understanding how to initialize the linked list in my constructor and adding items to it as well.

Here's my header file for it.

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
#ifndef CONGERA3_H
#define CONGERA3_H

const int MAX_STRING = 6;
typedef char Element300[MAX_STRING + 1];

class Queue300
{
    public:

    Queue300 ();
    Queue300 (Queue300 &old);
    ~Queue300();
    void enQueue300 (const Element300);
    void deQueue300 (Element300);
    void view300();

private:
    struct Node300;
    typedef Node300 * NodePtr300;
    struct Node300
    {
        Element300 element;
        NodePtr300 next;
    };
    NodePtr300 front, rear;
};

#endif 


Here's my implementation file as well. I've removed the other functions for now, I feel like if I can get the constructor and enQueue down I can figure out the rest of them.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include "congera3.h"
using namespace std;

Queue300::Queue300 ()
{
    front = NULL;

    return;
}

void Queue300::enQueue300 (const Element300 element)
{
   Node300 temp;
   temp.element = element;
}


I feel like I need to add a lot more to the constructor, such as setting the rear to point to the front. In the enQueue I think I need to have rear point towards the element I'm passing in and then have that element's next point towards front.
Topic archived. No new replies allowed.