#include <iostream>
#include<stdlib.h>
using namespace std;
double max(double *x,int n)//求数组中值得最大值
{
int i;double max;
max = x[0];
for(i = 1;i<n;i++)
if(x[i]>max)
max = x[i];
return max;
}
void fmin(double (*pointer)(double *x,int n),double *x)//传进来函数以及x值、
{
cout<<"success!"<<endl;
}
int main()
{
double *x;int n = 3;
x = (double *)malloc(sizeof(double)*n);
x[0] = 0;;
x[1] = 1;x[2] = 3;
double (*pointer)(double *x,int n);
pointer = max;
x[0] = pointer(x,n);
cout << "Hello world!"<<x[0] << endl;
fmin(pointer,x);//实现了feval的功能
return 0;
}
c++ 函数指针
最新推荐文章于 2023-10-17 11:06:18 发布