找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 352|回复: 1

看看这个程序怎么错了!

[复制链接]
发表于 2009-11-3 03:27:12 | 显示全部楼层 |阅读模式 IP:江苏扬州
#include "iostream.h"
#include "stdlib.h"
#define N 12

void process(float *p,int n,float (*fun)());
/*float arr_sum(float arr[],int n)
{
    int i;
    float sum=0;
    for(i=0;i<n;i++)
        sum+=arr[i];
    cout<<"数组和为:";
    return(sum);
}*/
void process(float *p,int n,float  (*fun)(float *p,int n))   //调用功能函数
{
    float result;
    result = (*fun)(p,n);
   
    cout<<result<<endl;
    return ;
}
float arr_odd(float *p,int n)
{
    int i;
    float sum=0;
    for(i=0;i<n;i+=2,p+=2)                    //这个地方值得自己好好学习
        sum+=*p;
    cout<<"奇数和:";
    return(sum);
}

/*float arr_max(float *p,int n)
{
    int i;
    float m;
    m = *p;
    for(i=0;i<n;i++,p++)
        if(*p>m)  m = *p;
        cout<<"最大值为:";
        return(m);

}

float arr_ave(float *p,int n)
{
    int i;
    float a;
    for(i=0;i<n;i++,p++)
        a+=*p;
        a=a/n;
        cout<<"平均值为:";
        return(a);

}*/

void main()
{
  int i;
  float a[N];
  cout<<"输入要选课的系统:";
  for(i=0;i<N;i++)
      cin>>a[i];
  float arr_odd(),(*pt)(float *p,int n);
  int n = N;
  pt = arr_odd();
  process(a,n,pt);
  //process(a,N,arr_odd);
  //process(a,N,arr_max);
  //process(a,N,arr_ave);
     
}

Compiling...
21function.cpp
D:\c++\book\21function\21function.cpp(20) : error C2197: 'float (__cdecl *)(void)' : too many actual parameters
D:\c++\book\21function\21function.cpp(68) : error C2440: '=' : cannot convert from 'float' to 'float (__cdecl *)(void)'
        There is no context in which this conversion is possible
D:\c++\book\21function\21function.cpp(71) : error C2664: 'process' : cannot convert parameter 3 from 'float (float *,int)' to 'float (__cdecl *)(void)'
        None of the functions with this name in scope match the target type
D:\c++\book\21function\21function.cpp(72) : error C2664: 'process' : cannot convert parameter 3 from 'float (float *,int)' to 'float (__cdecl *)(void)'
        None of the functions with this name in scope match the target type
执行 cl.exe 时出错.
那位仁兄帮忙看一下,小弟真实感激不尽啊!
发表于 2009-11-3 03:27:13 | 显示全部楼层 IP:江苏扬州
真是乱七八糟呀!float arr_odd(),(*pt)(float *p,int n);这是什么意思呀?定义还是调用?不懂…………
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 13:16 , Processed in 0.198697 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表