Container (hàng đợi) là đối tượng lưu trữ nhiều phần tử cùng kiểu hoặc khác kiểu. Phân loại:
- Sequence containers: array, vector, list
- Associative containers: set, map, multimap
- Unordered associative: unordered_set, unordered_map
- Container adapters: stack, queue
Ví dụ
#include <iostream>
using namespace std;
int main() {
int array[10] = {1,2,3,4};
for(int i = 0; i < 10; i++) cout << array[i] << " ";
return 0;
}
Đầu ra
1 2 3 4 0 0 0 0 0 0