구분 | Operations | Time Complexity |
---|---|---|
Constructor | - ClassName | |
--- | --- | --- |
Transformer | - push(value) | |
- pop() | ||
--- | --- | --- |
Observer | - size() | |
- isFull() | ||
- isEmpty() | ||
- isempty()-> top = -1 (top의 초기값을 -1로 설정) | ||
- pop -> top --; |
통으로된 데이터를 쪼개거나 쪼개진 데이터를 통합해서 쓸 때 유용하게 쓰임
ex) int -> 4byte지만 char 포인터로 읽어오면 1byte까지만 읽어옴
void make_array(){
int cnt = 0;
cin >> cnt;
~~int temp_array[cnt];
//~~→ code 실행 X
//(cuz 지역 변수의 size는 compile time에 결정되어야함!)
int* temp_array;
temp_array = new int[cnt]; // 동적할당
}
int main(){
make_array();
return 0;
}