Moved all function definitions into header files as required for templated classes/functions

This commit is contained in:
2022-11-12 23:34:32 +00:00
parent 5913fb8084
commit 96d5eb8071
8 changed files with 33 additions and 48 deletions

View File

@ -1,6 +0,0 @@
#include "linkedlist.h"
#include "linkedlistnode.h"
namespace Datastructures {
}

View File

@ -1,4 +1,6 @@
#pragma once
#include "linkedlistnode.h"
namespace Datastructures {
template <typename T>
class LinkedList

View File

@ -1,17 +0,0 @@
#include "linkedlistnode.h"
namespace Datastructures {
namespace Nodes {
template <typename T>
LinkedListNode<T>::LinkedListNode(T value, std::shared_ptr<LinkedListNode<T>> next) {
this->value = value;
this->next = next;
}
//Creates a new node, returning a smart pointer to a stack allocated object
template <typename T>
std::shared_ptr<LinkedListNode<T>> LinkedListNode<T>::create(T value, std::shared_ptr<LinkedListNode<T>> next) {
return std::make_shared<LinkedListNode<T>>(value, next);
}
}
}

View File

@ -15,5 +15,17 @@ namespace Datastructures {
private:
};
template <typename T>
LinkedListNode<T>::LinkedListNode(T value, std::shared_ptr<LinkedListNode<T>> next) {
this->value = value;
this->next = next;
}
//Creates a new node, returning a smart pointer to a stack allocated object
template <typename T>
std::shared_ptr<LinkedListNode<T>> LinkedListNode<T>::create(T value, std::shared_ptr<LinkedListNode<T>> next) {
return std::make_shared<LinkedListNode<T>>(value, next);
}
}
}