what's the difference between int (* f [])(); and int f[]();
2012-11-06 21:20
363 查看
i find this in Pointers on C
and:
i really want know what's the usage of the second one.
thank you.
以上是我的问题……感谢各种回答啊!外国网站……真是神速……瞬间有个人帮我改了格式,瞬间有了回复~
http://cdecl.org/ 这个是个好网站!
http://ideone.com/fzt1SX 这个是个好example~
http://stackoverflow.com/questions/13250777/whats-the-difference-between-int-f-and-int-f
突然觉得……怎么自己写的语言那么好理解……鸟语解释起来怎么就那么怪!
int f[](); /*this one is illegal*/因为f[][]这个表示数组的数组,那么f[]()就是函数的数组,因为数组是区别很大的,所以illegal
and:
int (* f [])(); /* this one legal. */ 这个就不一样了,表示的是一个指针数组,这个指针指向返回int的func
i really want know what's the usage of the second one.
thank you.
以上是我的问题……感谢各种回答啊!外国网站……真是神速……瞬间有个人帮我改了格式,瞬间有了回复~
http://cdecl.org/ 这个是个好网站!
http://ideone.com/fzt1SX 这个是个好example~
#include <stdio.h> int x = 0; int a() { return x++ + 1; } int b() { return x++ + 2; } int c() { return x++ + 3; } int main() { int (* abc[])() = {&a, &b, &c}; int i = 0, l = sizeof(abc)/sizeof(abc[0]); for (; i < l; i++) { printf("Give me a %d for %d!\n", (*abc[i])(), i); } return 0; }
http://stackoverflow.com/questions/13250777/whats-the-difference-between-int-f-and-int-f
突然觉得……怎么自己写的语言那么好理解……鸟语解释起来怎么就那么怪!
相关文章推荐
- What is the difference between static and global variables ?
- C++ Memory Management : What is the difference between malloc/free and new/delete?
- What is the difference between /dev/ttyUSB and /dev/ttyACM?
- What is the difference between Microsoft TMG and UAG ?
- What is the difference between GenericServlet, HttpServlet and a Servlet?
- What is the difference between new and malloc()?
- What is the difference between @staticmethod and @classmethod in Python?
- What is the difference between Constructor and ngOnInit?
- What is the difference between LWP and threads?
- What is the difference between AWT and SWT?
- What is the difference between supervised learning and unsupervised learning?
- What is the difference between Initializing and Assignment inside a constructor?
- What is the difference between SSH and SSL?
- What is the difference between Array.Clone and Array.Copy Method
- What is the difference between an EXE and a DLL?
- What are the difference between DDL, DML and DCL commands?
- What are the difference between DDL, DML and DCL commands[转]
- What is the difference between provider network and self-service network in OpenStack?
- What is the difference between Web Farm and Web Garden?
- What is the difference between procedural and nonprocedural language?