c – int(x)做什么?

c – int(x)做什么?,第1张

概述我已经看过这些,看起来似乎是c代码中的函数,但我不知道它们做了什么或它们是什么,它们似乎做类似于类型转换的东西,但它们看起来不像是类型转换,所以它们是什么? 它们看起来像这样:int(x)其中x是一些数字输入,我一直在网上查看,但我无法找到任何关于它们的信息(可能是因为我不知道它们被称为什么) . 有帮助吗? 这称为“功能表示法”,它是显式类型转换(“转换”)的一种形式. C 11,5.2.3: 我已经看过这些,看起来似乎是c代码中的函数,但我不知道它们做了什么或它们是什么,它们似乎做类似于类型转换的东西,但它们看起来不像是类型转换,所以它们是什么?

它们看起来像这样:int(x)其中x是一些数字输入,我一直在网上查看,但我无法找到任何关于它们的信息(可能是因为我不知道它们被称为什么) .

有帮助吗?

解决方法 这称为“功能表示法”,它是显式类型转换(“转换”)的一种形式. C 11,5.2.3:

5.2.3 Explicit type conversion (functional notation)

A simple-type-specifIEr (7.1.6.2) or typename-specifIEr (14.6) followed by a parenthesized Expression-List constructs a value of the specifIEd type given the Expression List. If the Expression List is a single Expression,the type conversion Expression is equivalent (in definedness,and if defined in meaning) to the corresponding cast Expression (5.4). If the type specifIEd is a class type,the class type shall be complete. If the Expression List specifIEs more than a single value,the type shall be a class with a suitably declared constructor (8.5,12.1),and the Expression T(x1,x2,…) is equivalent in effect to the declaration T t(x1,…); for some invented temporary variable t,with the result being the value of t as a prvalue.
总结

以上是内存溢出为你收集整理的c – int(x)做什么?全部内容,希望文章能够帮你解决c – int(x)做什么?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1220075.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存