trapzint.h
来自「《c++语言程序设计》例题程序」· C头文件 代码 · 共 31 行
H
31 行
//Begin of file Trapzint.h //文件一,类声明
#include <iostream.h>
#include <math.h>
class F //抽象类F的声明
{
public:
virtual double operator ()(double x) const=0; //纯虚函数重载运算符()
};
class Fun:public F //公有派生类Fun声明
{
public:
double operator()(double x) const //虚函数的内联实现
{
return log(1.0+x)/(1.0+x*x); //被积函数
}
};
class Integ //抽象类Integ声明
{
public:
virtual double operator ()(double a,double b,double eps) const=0;
};
class Trapz:public Integ //公有派生类Trapz声明
{
public:
Trapz(const F&pf):f(pf){} //构造函数
double operator ()(double a, double b,double eps) const;
private:
const F &f; //私有成员,F类对象的指针
};
//End of file Trapzint.h
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?