如此丑陋变态的C/C++的函数指针语法.~你看得懂吗?

cryincold 2006-02-11 05:52:10
const float *(*const*)(int)
这个函数指针类弄中间括号内那一大坨是什么东西呀..怎么const前后都有一个*呀.是干嘛用的啊?
上帝看得懂吗?????
555555555~~
反正我是看不懂~~~

出处:
今天在看今年比较流行的C++书<c++ common knowledge>
Item 54. Traits
Specializing ContainerTraits with any pointer type, whether it be int * or const float *(*const*)(int), will result in instantiation of this partial specialization, unless there is an even more specialized version of ContainerTraits available.
可以为其它pointer类型定制容器特性,无论指针是int*,还是const float *(*const*)(int)...晕~~~
...全文
322 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyi1982 2006-02-14
  • 打赏
  • 举报
回复
mark
healer_kx 2006-02-14
  • 打赏
  • 举报
回复
int* func(int)
{
return 0;
}

cout<<typeid(&func).name();
lbaby 2006-02-13
  • 打赏
  • 举报
回复
呵呵,const除了将其所修饰的量变为const 之外,不改变其它性质的,所以可以将它去掉了看
foochow 2006-02-13
  • 打赏
  • 举报
回复
根据右左法则很容易解析的。。
laofuxing 2006-02-13
  • 打赏
  • 举报
回复
语法就是这样定义的,自己的水平差,还说别人丑陋!
cryincold 2006-02-11
  • 打赏
  • 举报
回复
哈哈..我搞懂啦....
sankt 2006-02-11
  • 打赏
  • 举报
回复
学习
shikn 2006-02-11
  • 打赏
  • 举报
回复
const float *(*const*)(int)
分开看就好.

指向const型函数指针的指针, 那个函数的参数时int, 返回值时const float *

比如声名指针p
const float * foo(int){};
const float * (const * p1) (int);
const float *(*const*p)(int);

p1 = &foo;
p = &p1;

cryincold 2006-02-11
  • 打赏
  • 举报
回复
漏字了...
更正:
这个函数指针类型.....漏了一个型字.

64,642

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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