圆括号可以使用任意标识符作为参数吗? C ++ [英] Can parentheses take arbitrary identifiers as arguments? C++

查看:258
本文介绍了圆括号可以使用任意标识符作为参数吗? C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,是

(const int)* someInt;

有效的代码?

是不同于

const int* someInt;

推荐答案

您可以在表达式周围放置任意多个括号,而不改变其含义。但是你不能对类型做同样的事情。特别是,正如其他人所指出的,代码中的parenthese将声明的含义从声明更改为cast。

You can put arbitrarily many parentheses around expressions without changing the meaning. But you cannot do the same with types. In particular, as the others have pointed out, the parenthese in your code change the meaning from a declaration to a cast.

这篇关于圆括号可以使用任意标识符作为参数吗? C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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