일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Notting hill
- html5
- Polymorphism
- 알고리즘
- 파이썬
- Project
- dictation
- 코딩도장
- Euler
- cow
- for
- std
- Java
- bool
- UE4
- python
- Bull
- endl
- C++
- cout
- CSS
- font weight
- 영알남
- html
- Unreal
- if
- unreal engine4
- 파이선
- codecademy
- 연결리스트
- Today
- Total
연결 리스트 - 스택 본문
Student.h 파일
#include <cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
const int MAX_STRING = 100;
class Student {
int id;
char name[MAX_STRING];
char dept[MAX_STRING];
public:
Student(int i = 0, char* n = "", char* d = "")
{
set(i, n, d);
}
void set(int i, char* n, char* d) {
id = i;
strcpy_s(name, n);
strcpy_s(dept, d);
}
void display() {
cout << "학번 : " << id << " 이름 : " << name
<< " 학과 : " << dept << endl;
}
};
Node.h 파일
#include"Student.h"
class Node :public Student {
Node* link; //다음 노드를 가리킴
public:
Node(int id = 0, char* name = "", char* dept = "")
:Student(id, name, dept)
{
link = NULL;
}
~Node() {}
Node* getLink() { return link; }
void setLink(Node* p) { link = p; }
};
LinkedStack.h 파일
#include<iostream>
#include"Node.h"
using namespace std;
class LinkedStack {
Node* top;
public:
LinkedStack() { top = NULL; }
~LinkedStack() { while (!isEmpty()) delete pop(); }
bool isEmpty() { return top == NULL; }
void push(Node* p) {
if (isEmpty())
top = p;
else {
p->setLink(top);
top = p;
}
}
Node* pop() {
if (isEmpty()) return NULL;
Node* p = top;
top = top->getLink();
return p;
}
Node* peek() { return top; }
void display() {
cout << "[LinkedStack]" << endl;
for (Node* p = top; p != NULL; p = p->getLink())
p->display();
cout << endl;
}
};
'Programming > 기타 언어들' 카테고리의 다른 글
언리얼의 데이터 유형 (0) | 2017.05.18 |
---|---|
연결 리스트 - 큐 (0) | 2017.04.23 |
C++ rand() 함수 (0) | 2017.04.23 |
c++ 소수점 아래 고정 하기 (0) | 2017.04.15 |
C++ 자리수 다르게 출력 (0) | 2017.04.12 |