私はこのC++メソッドを使ってb2Fixtureインスタンスの配列を返そうとしています。このように定義されているJRContactインスタンスのシリーズ、の繰り返し処理:C++の意味論的な問題、ポインタへのconst value_type *
struct JRContact {
b2Fixture *fixtureA;
b2Fixture *fixtureB;
bool operator==(const JRContact& other) const
{
return (fixtureA == other.fixtureA) && (fixtureB == other.fixtureB);
}
};
n.b.コメントでエラーを参照してください、私はC++に見ず知らずの人よ、私はそのコードに;-)
を行っているかもしれない奇妙なものを言及することを躊躇しないで、次は(MacOSの上XCodeのコンパイラ)をコンパイルに失敗します。
id AbstractContactListener::getFixturesOfTypeCollidingWithFixture(b2Fixture *fix, int type){
std::vector<b2Fixture> fixtures;
std::vector<JRContact>::iterator ct;
JRContact contact;
for (ct = _contacts.begin(); ct != _contacts.end(); ct++){
contact = *ct;
if (
((fix == contact.fixtureA) || (fix == contact.fixtureB)) &&
(contactContainsType(contact, type))
){
if (fix == contact.fixtureA) {
// error: Semantic Issue: Reference to type 'const value_type' (aka 'const b2Fixture') could not bind to an lvalue of type 'b2Fixture *'
fixtures.push_back(contact.fixtureB);
}
else {
// error: Semantic Issue: Reference to type 'const value_type' (aka 'const b2Fixture') could not bind to an lvalue of type 'b2Fixture *'
fixtures.push_back(contact.fixtureA);
}
}
}
// error: Semantic Issue: No viable conversion from 'std::vector<b2Fixture>' to 'id'
return fixtures;
}
ありがとうございました!
パーフェクト、ありがとう! – Jem