diff --git a/DataStructures/src/LinkedList/linkedlistnode.cpp b/DataStructures/src/LinkedList/linkedlistnode.cpp index d0d8468..e8e6d2e 100644 --- a/DataStructures/src/LinkedList/linkedlistnode.cpp +++ b/DataStructures/src/LinkedList/linkedlistnode.cpp @@ -3,15 +3,15 @@ namespace Datastructures { namespace Nodes { template - LinkedListNode::LinkedListNode(T value, LinkedListNode* next) { + LinkedListNode::LinkedListNode(T value, std::shared_ptr> next) { this->value = value; this->next = next; } - //Creates a new node, returning a pointer to a stack allocated object + //Creates a new node, returning a smart pointer to a stack allocated object template - LinkedListNode* LinkedListNode::create(T value, LinkedListNode* next) { - return new LinkedListNode(value, next); + std::shared_ptr> LinkedListNode::create(T value, std::shared_ptr> next) { + return std::make_shared>(value, next); } } } \ No newline at end of file diff --git a/DataStructures/src/LinkedList/linkedlistnode.h b/DataStructures/src/LinkedList/linkedlistnode.h index dd9175c..1e9b3a0 100644 --- a/DataStructures/src/LinkedList/linkedlistnode.h +++ b/DataStructures/src/LinkedList/linkedlistnode.h @@ -7,10 +7,10 @@ namespace Datastructures { class LinkedListNode : public Generic::UndirectedNode> { public: - LinkedListNode(T value, LinkedListNode* next = nullptr); + LinkedListNode(T value, std::shared_ptr> next = nullptr); ~LinkedListNode(); - LinkedListNode* create(T value, LinkedListNode* next = nullptr); + std::shared_ptr> create(T value, std::shared_ptr> next = nullptr); private: