Skip to content

Instantly share code, notes, and snippets.

@poanchen
Created September 19, 2017 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poanchen/b30da978e2f7c4fbd6b34eb4c26f66b9 to your computer and use it in GitHub Desktop.
Save poanchen/b30da978e2f7c4fbd6b34eb4c26f66b9 to your computer and use it in GitHub Desktop.
Write a simple class template “LinkedListNode”, which stores an object of type “T” and a pointer to the next node of type “LinkedListNode*”. It doesn’t need to have any member functions.
// https://repl.it/LORG
#include <iostream>
using namespace std;
template <class T>
class LinkedListNode {
public:
T value;
LinkedListNode<T>* next;
};
int main()
{
LinkedListNode <int> currentNode, nextNode;
currentNode.value = 50;
currentNode.next = &nextNode;
nextNode.value = 60;
cout << "Current node value : " << currentNode.value << "\n";
cout << "Next node value : " << currentNode.next->value << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment