[C++ STL] Stack

2021. 4. 9. 00:45

1. Stack?

LIFO(Last In Last Out) 구조.

 

2. 사용법

# include <stack>

stack<int> s1;
stack<int> s2;
int x;

s1.push(x);	
s1.pop();
s1.top();
s1.size();
s1.empty();	// 비어있을 경우 true 반환.
swap(s1, s2);	// s1과 s2의 내용 바꾸기.

 

'C++' 카테고리의 다른 글

[C++ STL] List  (0) 2021.04.13
[C++] 표준 템플릿 라이브러리(STL: Standard Template Library)  (0) 2021.04.13
[C++ STL] find  (0) 2021.04.10
[C++ STL] Set  (0) 2021.04.10
[C++ STL] Vector  (0) 2021.04.09

+ Recent posts