데이터가 차곡차곡 쌓인 형태의 자료 구조로, 가장 마지막에 입력된 데이터가 가장 먼저 출력되는 후입선출(LIFO, Last In First Out) 방식
#include <iostream>
#include <stack>
using namespace std;
int main() {
stack<int> s, b, c, arr[10];
s.push(10); // 마지막 위치에 데이터 삽입
s.push(20);
s.push(30);
printf("%d\n", s.top()); // 마지막 데이터
s.pop(); // 마지막 데이터 삭제
printf("%d\n", s.top()); // 마지막 데이터
printf("%d\n", s.size()); // 스택 크기
printf("%d\n", s.empty()); // 비어있으면 1 아니면 0
arr[2].push(10); // 스택 배열
b.push(20);
// printf("%d\n", c.top()); // 비어있는데 접근하면 터진다.
}