多次元配列をどのようにループしますか?次のようなことがあったとしましょう。
class blah
{
public:
blah();
bool foo;
};
blah::blah()
{
foo = true;
}
blah testArray[1][2];
testArray[1][0].foo = false;
foo
のどれが偽であるかを見つけるために testArray
をループする方法はありますか?
ベストアンサー
class blah
{
public:
blah();
bool foo;
};
blah::blah()
{
foo = true;
}
int testArrayFirstLength = 1;
int testArraySecondLength = 2;
blah testArray[testArrayFirstLength][testArraySecondLength];
testArray[1][0].foo = false;
for (int i = 0; i < testArrayFirstLength; i++) {
for (int j = 0; j < testArraySecondLength; j++) {
if (!testArray[i][j]) {
blah thing = testArray[i][j]
}
}
}
それは良い?あなたは何か他のものを探していましたか?