#include<cstdlib>#include <process.h>#include <iostream.h>#include <conio.h>#include <stdlib.h>#include <math.h>double number1,number2,answer,val;class oopcalc {public:void calcadd();void calcsub();void calcdiv();void calcmult();double calcmixed();//hun he yun suanvoid test();//ce shivoid calcfartocel();void calcceltofar();void calcsroot();void exitprog();void menu();void badinput();private:double add(double x, double y);double sub(double x, double y);double div(double x, double y);double mult(double x,double y);double mixed();double fartocel(double x);double celtofar(double x);double sqroot(double x);};.........double oopcalc::calcmixed(){char p[80];//计算公式存储数组int n;//数组下标double isnumber();//分析数据double addnumber();//加减函数double exenumber();//乘除函数double isnumber()//分析公式数据{double num;if(p[n]=='('){n++;num=addnumber();if(p[n]!=')'){cout<<"算式有误!!\n";system("pause");exit(-1);}n++;return num;}if(!isdigit(p[n])){if(p[n]=='-'){num=0;return num;}cout<<"算式有误!!\n";system("pause");exit(-1);}num=atof(p+n);while(isdigit(p[n]) || p[n]=='.')n++;return num;}double addnumber(){//加减法double num,p1;num=exenumber();while(p[n]=='+' || p[n]=='-'){char x=p[n];n++;p1=exenumber();if(x=='+') num+=p1;if(x=='-') num-=p1;}return num;}double exenumber(){//乘除法double num,p2;num=isnumber();while(p[n]=='*' || p[n]=='/'){char x=p[n];n++;p2=isnumber();if(x=='*')num*=p2;if(x=='/')num/=p2;}return num;}double num=0;do {cout<<"输入计算公式:(exit=退出) ";cin>>p;num=addnumber();cout.precision(16);cout<<"计算结果为: "<<num<<endl;cout<<endl;n=0;}while(strcmp(p,"exit"));return 0;};}......void main(){oopcalc s;s.menu();cout<<endl;}
參考答案:C++不能在函数内部定义其他函数。