- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Type Casting
Type Casting 类型转换 Converting an expression of a given type into another type is known as type-casting. We have already seen some ways to type cast: 转换一个给定类型到其他类型的表达式被认为是“类型转换”。我们已经看到一些通向类型转换的途径: Implicit conversion 隐式转换 Implicit conversions do not require any operator. They are automatically performed when a value is copied to a compatible type. For example: 隐式转换的执行不需要任何操作符,当一个值复制到与其兼容类型的值时,隐式转换会自动执行。例如: 123 short a=2000; int b; b=a; Here, the value of a has been promoted from short to int and we have not had to specify any type-casting operator. This is known as a standard conversion. Standard conversions affect fundamental data types, and allow conversions such as the conversions between numerical types (short to int, int to float, double to int...), to or from bool, and some pointer conversions. Some of these conversions may imply a loss of precision, which the compiler can signal with a warning. This can be avoided with an explicit conversion. 这里,a的值将从短整型提升到整型,并且我不需要指定任何类型转换的操作符。这被认为是一种标准的转换。标准转换作用于基本数据类型,并且允许像这样的一些转换:从数值类型(short to int, int to float, double to int...)到bool两者之间的相互转换,以及一些指针的转换。编译器会对这些转换中有些可能隐含精度损失的转换预示警告,这是可以使用显示转换避免的。 Implicit conversions also include constructor or operator conversions, which affect classes that include specific constructors or operator functions to perform conversions. For example: 隐式转换也包含构造器或运算符的转换,这作用于包含指定构造器或操作符执行转换的功能的类。例如: 12345 class A {}; class B { public: B (A a) {} }; A a; B b=a; Here, a implicit conversion happened between objects of class A and class B, because B has a constructor that takes an object of class A as parameter. Therefore implicit conversions from A to B are allowed. 这里,一个隐式转换发生在类A和类B之间,因为B有一个取类A的一个对象作为参数的构造器。所以允许从A到B的隐式转换。 Explicit conversion 显示转换 C++ is a strong-typed language. Many conversions, specially those that imply a different interpretation of the value, require an explicit conversion. We have already seen two notations for explicit type conversion: functional and c-like casting: C+
有哪些信誉好的足球投注网站
文档评论(0)