C++のpush_back
主にSTL(Standard Template Library)のstd::vectorやstd::dequeなどのコンテナで使用されるメソッドで、コンテナの末尾に新しい要素を追加する
#include <iostream>
#include <vector>
int main() {
// std::vectorを定義
std::vector<int> numbers;
// 要素を追加
numbers.push_back(10);
numbers.push_back(20);
numbers.push_back(30);
// コンテナの内容を表示
for (int num : numbers) {
std::cout << num << " ";
}
return 0;
}
↑の実行結果は10 20 30