Need clear explanation

Can someone explain in details what this linked list do. I've been having trouble with linked list in c++. I understand it for the most part ,but I want to make sure im 100% correct. I've created some programs using linked list ,but for the most part its pure guessing and working around it. So can anybody please explain the following code to me in detail. Like the most detailed explanation will be nice if you have the time.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
     Booksptr N = new Books;
    N ->next = NULL;
    N->Pages = AddData;
    if (head != NULL)
    {
        curr = head;
        while (curr->next != NULL)
        {
            curr = curr->next;
        }
        curr->next = N;
    }
    else
    {
       head = N; 
    }

}

--Blackhart
I understand it for the most part ,but I want to make sure im 100% correct.

Then it would better, if you do explain the code for us first (as well as you can). Then we'll know where you need help the most.
Last edited on
@keskiverto
Thanks I understand everything about link list in general.
Breakdown:
Does calling N, temp and curr in different parameters at the same time change the value of the functions altogether. Heres the code
(The Breakdown wasn't longer because I actually explained somethings to myself)
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
#include <iostream>
#include <vector>
//Coded by Justin Young
// If using code for website ask for permission

using namespace std;
class List
{
private: 
   typedef struct Books 
   {
       int Pages;
       *Books next;
   }*Booksptr;
   Booksptr head;
   Booksptr curr;
   Booksptr temp;
public:
    List();
    void AddNode (int AddData);
    void DeleteNode (int delData);
    void PrintList ();
    
};
List::List()
{
    head = NULL;
    curr = NULL;
    temp = NULL;
}
void List::AddNode(int AddData)
{
    Booksptr N = new Books;
    N ->next = NULL;
    N->Pages = AddData;
    if (head != NULL)
    {
        curr = head;
        while (curr->next != NULL)
        {
            curr = curr->next;
        }
        curr->next = N;
    }
    else
    {
       head = N; 
    }

}
void List::DeleteNode(int delData)
{
    Booksptr delPtr = NULL;
    temp = head;
    curr = head;
    while(curr != NULL && curr->Pages != delData){
        temp = curr;
        curr = curr->next;
    }
    if (curr = NULL){
        cout << delData << "there were no books containing that " << endl;
        delete delPtr;
    }
    else{
        delPtr = curr;
        curr = curr->next;
        temp -> next = curr;
        delete delPtr;
        cout << "The value " << delData << "Was deleted " << endl;
        
    }
}
int main()
{



}

If it's possible can someone just explain how the whole link list move in terms of linking. I got this code from a tutorial from Youtube. I just need some explanation as of how the node transverse througout the linked list. If that makes sense if not totally understandable I know I can be a bit confusing at times. To really say what I want to say is explain how parameters work in an Linked List.
--Blackhart
What do you mean with "parameters" and with "list move"?
Topic archived. No new replies allowed.