编译是这样的:#include <stdio.h>#define M 8void main (){float sumf,sump;float a[M]={11,2,-3,4.5,5,69,7,80};float (*p) ();float max (float a[],int n);p=max;sump=(*p) (a,M);sumf=max(a,M);printf ("sump=%.2f\n",sump);printf ("sumf=%.2f\n",sumf);}float max (float a[],int n){int k;float s;s=a[0];for (k=0;k<n;k++)if (s<a[k])s=a[k];return s;}是从书上照打下去的但编译时却有问题:D:\fiend++\8.7.cpp(9) : error C2440: '=' : cannot convert from 'float (__cdecl *)(float [],int)' to 'float (__cdecl *)(void)'This conversion requires a reinterpret_cast, a C-style cast or function-style castD:\fiend++\8.7.cpp(10) : error C2197: 'float (__cdecl *)(void)' : too many actual parameters
- 2 回答
- 0 关注
- 71 浏览
添加回答
举报
0/150
提交
取消