12345678
if (MemberOne.nAge==50) { //Do this } else if (MemberTwo.nAge=50) { //Do this } etc...
12345678910111213141516171819
class Foo { public: int var; Foo():var(0){}; } int main() { Foo MyFoos[10]; for(int i = 0; i < 10; ++i) { if(MyFoos[i].var == x) { //Do something } } return 0; }
123456789101112131415161718192021222324252627282930
class Ages { public: int ages; }; int main() { Ages Member[10]; Member[0].ages = 28; Member[1].ages = 35; Member[2].ages = 42; //etc....... for (int i = 0; i < 10; i++) { if (Member[i].ages == 50) { //do something } } return 0; }