我希望能够遍历从共同祖先继承的类的列表。遍历类列表
什么,我想(类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