Last active
January 1, 2018 14:23
-
-
Save meylady/278fc382cc0289b66dbbf62d17e9739e to your computer and use it in GitHub Desktop.
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
#include <cstdio> | |
#include <iostream> | |
using namespace std; | |
template <typename T> | |
class Node { | |
public: | |
T data; | |
Node *next; | |
Node(){} | |
Node(T data):data(data) { | |
this->next = NULL; | |
} | |
Node *head = NULL; | |
void addNode(T data) { | |
Node *newNode = new Node(data); //새로운 노드생성 | |
if (head == NULL) { | |
head = newNode; | |
} | |
else { | |
newNode->next = head; | |
head = newNode; | |
} | |
printf("%d\n", &newNode->data); | |
} | |
}; | |
int main() { | |
Node <int> data; | |
for (int i = 1; i <= 10; i++) { | |
data.addNode(i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment