I have a Doubly Linked List and Node template. I want to implement an object of type LinkedList within the structure from which I create the main LinkedList. The problem I have is that I don't quite understand how to access the internal list.
MyNode receives a structure to create the nodes that go inside the Linked List; so I want to access a Linked List which will be inside the main structure. I have no idea how to do this, I'm so lost.
I attach my LL template and my structure declaration.
And then I only allocated memory inside my void main(). Please I need help.
Template:
#pragma once
#ifndef LL
#define ll
template <class T1> struct Nodo {
public:
T1 info;
Nodo* prev;
Nodo* next;
Nodo(){ }
Nodo(T1 data)
{
this->info = info;
}
~Nodo() {}
};
template <class T> class ListaLigada
{
public:
T* head=NULL, *tail=NULL;
ListaLigada();
void AddNodo(T nodo);
};
template <class T> void ListaLigada<T>::AddNodo(T nodo)
{
T* aux = NULL;
aux = new T(nodo);
aux->next = NULL;
aux->prev = NULL;
if (head == NULL)
{
head = aux;
tail = aux;
}
else
{
tail->next = aux;
aux->prev = tail;
tail = aux;
}
}
#endif