wzs*_*sun 6 c++ operators char
嘿,我想知道你怎么能把一个角色'+'变成一个算子.例如,如果我有
char op = '+'
cout << 6 op 1;
谢谢.
简单的方法是使用switch语句
switch (op)
{
case '+':
  res = x + y;
  break;
case '-':
  res = x - y;
  break;
case '*':
  res = x * y;
  break;
}