如何使用数字参数创建操作方法(int op),以便通过操作(1)或操作(3)调用其他方法?我想我需要创建一个开关,但我不知道如何。C++中的调用方法
int subtraction(int n1, int n2) { //e.g. of simple method
return n1 - n2;
}
int multiplication (int n1, int n2){
return n1*n2;
}
int operation(int op) {
// code that will call the method subtraction when I press 1.
// same for multiplication...
}
int main() {
}
你问如何使用'if'语句? – 2014-10-26 14:49:33
为什么不参加讲座并学习这些东西? – 2014-10-26 14:49:49
我想他在问如何使用'switch'语句。 – Westbrook 2014-10-26 14:50:24