Singly Linked List Implementation (With Nodes)
up vote
0
down vote
favorite
This code was recommended to me by my dear friend Jon after I wrote an implementation using arrays. With his help, I managed to create a Singly linked List similar to std::vector using Nodes. #include <iostream> template <class T> class LinkedList { private: size_t _size; public: class Node { public: Node* next; T value; Node(T val) : value(val), next(NULL) {} }; Node* head; LinkedList() : _size(0), head(NULL) {} ~LinkedList() { std::cout << "Linked List Deleted!" << std::endl; } void push(T val) { Node* node = new Node(val); node->next = head; head = node; ++_size; } size_t size() { return _size; } bool em...