如何使用數字參數創建操作方法(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