I'm currently working on some of my code. I'm trying to learn how the "List Class" from the STL library works under the hood. I can't seem to quite understand the process of removing a node from a list made by the user. Is there any information that is accessible that would better help me wrap my head around this problem.
#include <iostream>
#include <string>
using namespace std;
class Node {
public:
string todos;
Node* next;
Node(string todos) {
this->todos = todos;
next = NULL;
}
};
void print_list(Node* head) {
Node* temp = head;
while (temp != NULL) {
cout << temp->todos << " ";
temp = temp->next;
}
}
Node* takeinput() {
string var;
int num;
Node* head = NULL;
Node* tail = NULL;
cout << "Please enter 5 Todo tasks. " << endl;
cout << endl;
cout << "If you would like to exit this prompt please enter 'End' " << endl;
cout << "If you would like to enter an item onto the list please press 1 " << endl;
cout << endl;
cin >> num;
while (var != "End") {
if (num == 1) {
Node* newNode = new Node(var);
if (head == NULL) {
head = newNode;
tail = newNode;
}
else {
tail->next = newNode;
tail = tail->next;
}
}
cin >> var;
if (num == 2) {
}
}
return head;
}
int main()
{
string hello;
Node* head = takeinput();
print_list(head);
}