Created
September 19, 2017 04:11
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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