标题:typedef(*funtype)(int x);定义问题请高手回答
取消只看楼主
scorpionchac
Rank: 1
等 级:新手上路
帖 子:34
专家分:6
注 册:2015-10-20
结帖率:75%
已结贴  问题点数:10 回复次数:2 
typedef(*funtype)(int x);定义问题请高手回答
#include<stdio.h>
void myfun1(int x);
void myfun2(int x);
void myfun3(int x);
typedef(*funtype)(int x);//好像只能在C++中调试通过?????
void callmyfun(funtype fp,int x);
int main(int argc,char*argv[])
{
    callmyfun(myfun1,10);
    callmyfun(myfun2,20);
    callmyfun(myfun3,30);
    }
 void callmyfun(funtype fp,int x)
 {
     fp(x);
 }
 void myfun1(int x)
 {
     printf("函数myfun1输出:%dn",x);
 }
 void myfun2(int x)
 {
     printf("函数myfun2输出:%dn",x);
 }
 void myfun3(int x)
 {
     printf("函数myfun3输出:%dn",x);
 }
typedef(*funtype)(int x)这一句是不是在C_free中不能定义啊?显示[Error] G:\Program Files (x86)\C-Free 5\mingw\include\指针引用.cpp:5: error: ISO C++ forbids declaration of `funtype' with no type请高手回答?
搜索更多相关主题的帖子: include 
2015-12-21 20:16
scorpionchac
Rank: 1
等 级:新手上路
帖 子:34
专家分:6
注 册:2015-10-20
得分:0 
C-free好像不行啊!!在c-free下盖怎么搞啊

小菜鸟
2015-12-21 21:01
scorpionchac
Rank: 1
等 级:新手上路
帖 子:34
专家分:6
注 册:2015-10-20
得分:0 
呵呵??谢谢
typedef void (*funtype)(int);这句我忘了写void结果不能通过
谢谢指导

小菜鸟
2015-12-22 19:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-460437-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.259639 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved