如果我要创建一个类并将多个函数放入私有部分,我将如何从同一个类的公共部分调用这些函数?例子:
class calculator{
public: //What would go here
private:
float calculate(float x, char y, float z){
float answer;
switch (y){
case '+':
answer = x + z;
break;
case '-':
answer = x - z;
break;
case '/':
answer = x / z;
break;
case '*':
answer = x * z;
break;
default:
return(0);
}
cout <<"= "; return answer;
}
void main(){
float num1;
float num2;
char aOp;
system("CLS");
cout << ">> "; cin >> num1 >> aOp >> num2;
cout << calculate(num1, aOp, num2) << endl << endl;
}
};