【初心者歓迎】C/C++室 Ver.14【環境依存OK】
■ このスレッドは過去ログ倉庫に格納されています
0207デフォルトの名無しさん
05/03/09 01:54:09要素が構造体テンプレートの場合の例。
#include <algorithm>
#include <vector>
#include <iostream>
int main()
{
std::vector<std::pair<int, int> > foo;
foo.push_back(std::make_pair(0, 1));
foo.push_back(std::make_pair(1, 2));
for (std::vector<std::pair<int, int> >::iterator it = foo.begin(); it != foo.end(); ++it) {
std::cout << it->first << '\n';
}
return 0;
}
斯くの如く、普通にアロー演算子を使うだけ。
■ このスレッドは過去ログ倉庫に格納されています