int (*foo())()和int (*foo[])()

wangguilin 2008-10-30 03:45:15
请问这两个是什么意思?
...全文
622 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
kaxin008 2012-03-24
  • 打赏
  • 举报
回复
求详细解释~~~
jia_xiaoxin 2008-10-30
  • 打赏
  • 举报
回复
int (*foo())() 定义了一个函数指针 foo
int (*foo[])() 定义了一个未初始化元素个数的函数数组指针
e_sharp 2008-10-30
  • 打赏
  • 举报
回复
仔细看一下 帅 给你的连接

http://www.cppblog.com/luliang/archive/2008/09/15/61863.html?opt=admin
e_sharp 2008-10-30
  • 打赏
  • 举报
回复
int (*foo())()
foo是一个函数,返回值是一个函数指针 int(*)()

int (*foo[])()
foo数组,元素类型是函数指针 int(*)()
  • 打赏
  • 举报
回复

int (*foo())()// foo() 函数 返回类型为int(*)(),即一个函数指针
int (*foo[])()//foo数组元素的类型是 函数指针。简单看就这样 int(*p)()
帅得不敢出门 2008-10-30
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 cyj626 的回复:]
引用 1 楼 lbh2001 的回复:
int (*foo())() ---> 参数为空的foo函数返回类型是一个指向参数为空返回值类型为int的函数指针
int (*foo[])() ---> foo数组元素的类型是一个指向参数为空返回值类型为int的函数指针

学习,读的好辛苦啊,有没有简单的分析法啊
[/Quote]
有 叫右左法则
http://www.cppblog.com/luliang/archive/2008/09/15/61863.html?opt=admin
cyj626 2008-10-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lbh2001 的回复:]
int (*foo())() ---> 参数为空的foo函数返回类型是一个指向参数为空返回值类型为int的函数指针
int (*foo[])() ---> foo数组元素的类型是一个指向参数为空返回值类型为int的函数指针
[/Quote]
学习,读的好辛苦啊,有没有简单的分析法啊
lbh2001 2008-10-30
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 liubuweiright 的回复:]

我原以为是
int (*foo())() ---> foo是一个指向参数为空返回值类型为int的函数指针
int (*foo[])() ---> 这个不知道怎么用,编译没通过
[/Quote]
你缺少数组元素的个数当然编译不通过
liubuweiright 2008-10-30
  • 打赏
  • 举报
回复

我原以为是
int (*foo())() ---> foo是一个指向参数为空返回值类型为int的函数指针
int (*foo[])() ---> 这个不知道怎么用,编译没通过
lbh2001 2008-10-30
  • 打赏
  • 举报
回复
int (*foo())() ---> 参数为空的foo函数返回类型是一个指向参数为空返回值类型为int的函数指针
int (*foo[])() ---> foo数组元素的类型是一个指向参数为空返回值类型为int的函数指针

70,022

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧