I m 试图在以下一栏中宣布变数:
int main(int argc, char *argv[]) {
if (argv[3] == string("simple")) {
Player & player = *get_Simple();
} else if (argv[3] == string("counting")) {
Player & player = *get_Counting();
} else if (argv[3] == string("competitor")) {
Player & player = *get_Competitor();
}
// More code
}
但是,在我试图汇编以下错误时,我会发现:
driver.cpp:38: error: unused variable ‘player’
driver.cpp:40: error: unused variable ‘player’
driver.cpp:42: error: unused variable ‘player’
driver.cpp:45: error: ‘player’ was not declared in this scope
任何想法?