Image sequence: declaration of a class function, function, main function, an example of the book,






CodePudding user response:
Really don't want to enter this program again, it is best you will post program, then answer people can COPY down to debug the program,CodePudding user response:
# # ifndef HEAD_H_INCLUDED
# define HEAD_H_INCLUDED
The class Function {
Public:
Const virtual double operator () (double x)=0;
~ the Function () {}
};
The class fun: public Function {
Public:
Virtual double operator () (double x) const;
};
The class integ {
Public:
Virtual double operator () (double a, b double, double esp) const=0;
~ integ () {}
};
The class integration: public integ {
Public:
Integration (const Function& F) : f (f) {}
Virtual double operator () (double a, b double, double esp) const;
Private:
Const Function & amp; f;
};
# endif//HEAD_H_INCLUDED
# include "head h"
# include
Double fun: : operator () (double x) const {
Return the log (1.0 + x)/(1.0 + x x x);
}
Double integration: : operator () (double a, b double, double esp) const {
Bool IO=false;
Int n=1;
Double t2n=0;
Double h=b - a;
Double tn=h * (f (a) + f (b))/2;
Do {
Double sum=0;
for(int i=0; iThe sum +=f (a + 0.5 + I);
}
T2n=sum (tn + h *)/2.0;
If (fabs (t2n - tn) & lt; Esp) {
IO=true;
} else {
Tn=t2n;
H/=2;
N *=2;
}
} while (! IO);
Return t2n;
}
# include & lt; Iostream>
# include "head h"
# include "5.10. CPP
"
using namespace std;
Int main ()
{
Fun x;
Integration a (x);
cout<" E? 3?? A "& lt;<" ? On "& lt; return 0;
}