Doubly linked list constructor with vector inside c++


New Member
I am new to c++ and am working on an assignment involving vectors and a doubly linked list. I am given this struct as such.
struct Node {
std::vector<T> data;
Node<T>* next;
Node<T>* prev;
Node(): next(nullptr), prev(nullptr){} };
I am now required in another class to create a constructor for this Node to be used for various methods. I understand that the struct already has an initialization list for next and prev, I think I am just overthinking what the constructor should be.
Class LinkedVector {
Node<T>* head;

    head = NULL;
Is this the correct way of constructing the linked list? Again I am new to c++ and any help pointing me in the right direction is most helpful. Thank you and have a great day.


Thành viên BQT
Yes, that is almost correct, you want to set head to nullptr instead of NULL of course.

Then when you create methods to add to the list you will need to check if it is empty and if so initialize head rather than adding an element elsewhere.