这两个声明有什么区别 [英] what is the difference between these two declarations

查看:77
本文介绍了这两个声明有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int *f()
int (*f)()

推荐答案

int *f();


f 是一个函数,它返回一个指向整数的指针.


f is a function returning a pointer to an integer.

int (*f)();


f 是指向函数的指针(指向函数返回一个整数值).


f is a pointer to a function (pointed function returns an integer value).


第一个将f声明为指向类型的指针的变量int.
第二个将f声明为类型函数的变量,不带任何参数返回int

P.P.S .:我错了,正如CPallini指出的那样,第一个是函数声明.有关说明,请访问本周第一大师 [
The first declares f as a variable of type pointer to int.
The second declares f as a variabvle of type function with no parameters returning an int

P.P.S.: I was wrong, the first is a function declaration, as CPallini pointed out. Explanations can be found at Guru Of The Week #1[^]


这篇关于这两个声明有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆