Skip to content

Instantly share code, notes, and snippets.

@meylady
Last active January 1, 2018 14:23
Show Gist options
  • Save meylady/278fc382cc0289b66dbbf62d17e9739e to your computer and use it in GitHub Desktop.
Save meylady/278fc382cc0289b66dbbf62d17e9739e to your computer and use it in GitHub Desktop.
#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