Input a node into Linked List

Hi there..
I am working with simple linked list which adds a node; to just understand how it works; and pre-try for my assignment.
The question is, How can I add a node into my linked list with multiple items?
I learned how to add a single value. But I am stuck in here; cant work with multiple items as a node.
Can anyone help me?

Here is my try...

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
#include <iostream>
using namespace std;

class Course{
private:
      string title;
      string days;
      string time;

public:
    Data item;
    Course *next;

    int input(Data item)
    {
        cout<<endl;
        cout<<"Enter course title: ";
        getline(cin, item.title);

        cout<<"Mention days for the course: ";
        cin>>item.days;

        cout<<"Mention time of the course: ";
        cin>>item.time;

        return item;
    }

		void add_course(Course *&head, Data x)
		{
			if(!head){
				head = new Course;
				head->value = x;
				head->next = NULL;
			}
			else
				return add_course(head->next , x);
		}
};

int main(){
	Course *head = NULL, A;
	Data item, n;

    item = A.input(n);
    A.add_course(head, item);

    return 0;
}
Last edited on
Topic archived. No new replies allowed.