我希望能夠遍歷從共同祖先繼承的類的列表。遍歷類列表
什麼,我想(類Python語法,因爲這是我來自語言)精縮版:
const *Player *PLAYERS[3] = { *PlayerTypeOne, *PlayerTypeTwo, *PlayerTypeThree};
int outcome = 0;
for player in players {
if (doThingWithPlayer((&player)(), some, other, variables) == true) {
outcome++;
}
}
如果這不是在做這種操作的首選方式,諮詢如何我應該繼續非常歡迎。
排序的代碼,我想避免的是:
int outcome = 0;
PlayerTypeOne player_one();
if doThingWithPlayer(player_one, some, other, variables){
outcome++;
}
PlayerTypeTwo player_two();
if doThingWithPlayer(player_two, some, other, variables){
outcome++;
}
PlayerTypeThree player_three();
if doThingWithPlayer(player_three, some, other, variables){
outcome++;
}
類的列表類的實例(即對象)的列表? – NPE
你混淆了'object'和'class'這兩個詞嗎? –
@NPE類的列表 – muddyfish