-2
我想开发一个独特的计算器。所以,我玩它,但现在我真的很困惑这个功能:C++基本计算器 -
//Calculate two input expressions.
@prvni - First expression.
@druhe - Second expression.
@operace - Specifies mathematical operations - addition, multiplication etc.
int vypocti(int prvni, int druhe, char operace){
return (prvni+operace+druhe);
}
所以,我试图使用“operace”参数作为数学函数。 (如下所示)
if(dpik == '+'){
cout<<vypocti(prvni, druhe, '+');
}
你能帮我吗?
您不能这样,C++不是脚本语言。你必须映射它来调用正确的数学operaiton:'if(operace =='+'){return prvni + druhe; }' –