공통 조상으로부터 상속받은 클래스 목록을 반복 할 수 있기를 원합니다.클래스 목록 반복하기
나는 (파이썬 같은 그게 내가에서오고 언어의 같은 구문) 원하는 것을축소 된 버전이 작동 이런 종류의 일을 선호하는 방법이 아닌 경우
const *Player *PLAYERS[3] = { *PlayerTypeOne, *PlayerTypeTwo, *PlayerTypeThree};
int outcome = 0;
for player in players {
if (doThingWithPlayer((&player)(), some, other, variables) == true) {
outcome++;
}
}
가 조언하는 방법에 나는 계속해야한다 매우 환영한다.
내가 피하고 싶은 코드의 종류는 다음과 같습니다 당신은 factory design pattern를 찾고 있습니다
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