Linked list that needs multiple data fields

Hi all, I am trying to make a linked list of assignments, one that would keep track of homework. I was told to do it in the form of a doubly linked list, where each node would be able to point to previous and next, and contain data of the assignments due date, assigned date, title, and status (completed, late, currently assigned).

I have made a linked list with just a data pointer, where it would return a single number back to me and not have an issue. But I am unsure on how to get it to return 4 different entries back to me.

My Header file:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  #pragma once
#include <string>
using namespace std;
class Assigned
{
private:
	typedef struct node
	{
		node* next;
		node* prev;
		string data;
		enum status { late, assigned, completed };
		int dueDate;
		int assignedDate;
	}*nodePtr;
	nodePtr head;
	nodePtr curr;
	nodePtr temp;
public:
	Assigned();
	void displayAssignments(); 
	void addAssignment(string name, int dueDate, int assignedDate);

};


My cpp file:
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
// dataNodeWithMultipleEntries.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Header1.h"
#include <string>
#include <iostream>

using namespace std;

Assigned::Assigned()
{
	head = NULL;
	curr = NULL;
	temp = NULL;

}
void Assigned::displayAssignments() 
{
	curr = head;
	while (curr != NULL)
	{
		cout << curr->dueDate << curr->assignedDate << endl;
		curr = curr->next;
	}
}
void Assigned::addAssignment(string name, int dueDate, int assignedDate)
{

}

int main()
{
    return 0;
}


My problem is that I can make a node with just next/prev pointers and a data field, but when it comes to having 4 different kinds I get a little lost. Also I know my addAssignment is lacking my enum status, I am still trying to figure out how those work too. Any help is appreciated, thanks!
Last edited on
I don't understand what makes it harder having four data values instead of one. If you prefer you could create another struct that contains the four values.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct node_data
{
	string title;
	enum status { late, assigned, completed };
	int dueDate;
	int assignedDate;
};

struct node
{
	node* next;
	node* prev;
	
	node_data data;
};
Last edited on
Topic archived. No new replies allowed.