Q&A
提示コードですが変数i
の部分ですが二重目のイテレーターで変数i
を利用してbegin()
に加算して一重目と同じ物を参照しないようにしているのですが。この変数i
を利用しない方法ありますでしょうか?
調べたのですが参考になる記事が出来ません。
参考サイト:http://vivi.dyndns.org/tech/cpp/iterator.html
cpp
1 2/*################################################# 3# 更新 4###################################################*/ 5void Game::Update() 6{ 7 8 for(std::vector<std::shared_ptr<SDL::GameObject>>::const_iterator itr = gameObject.begin(); itr != gameObject.end(); itr++) 9 { 10 (*itr)->Update(); 11 } 12 13 int i = 1; 14 for(std::vector<std::shared_ptr<SDL::GameObject>>::const_iterator itr = gameObject.begin(); itr != gameObject.end(); itr++) 15 { 16 for(std::vector<std::shared_ptr<SDL::GameObject>>::const_iterator it = gameObject.begin() + i; it != gameObject.end(); it++) 17 { 18 (*itr)->Collision(*it); 19 } 20 i++; 21 } 22 23 24} 25
こちらの質問が他のユーザーから「やってほしいことだけを記載した丸投げの質問」という指摘を受けました。
回答1件
良いと思った回答にはグッドを送りましょう。
グッドが多くついた回答ほどページの上位に表示されるので、他の人が素晴らしい回答を見つけやすくなります。
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。