用于把指针类型转换到整形以及转回到指针类型。
It is used to cast a pointer type to a wide enough integral type and back to the original pointer type.
一个空指针到另一个指针类型转换产生一个空的指针类型。
Conversion of a null pointer to another pointer type yields a null pointer of that type.
因此,需要注意将整数值转换为指针类型的应用程序。
Therefore, applications casting integer values to pointer types might need attention.
定义整型类型,任何有效指针都可以转换成这个类型。
Define integer types to which any valid pointer to void can be converted.
比范围更加微妙的是指针和整型之间的转换;由于这些转换通常都包括强制类型转换,因此编译器很难告诉您到底做错了什么。
More subtle than ranges are conversions between pointers and integers; because these conversions generally involve casts, it's hard for the compiler to tell you what you're doing wrong.
解决方案是将浮点变量的地址强制转换成一个指向整型类型的指针,如下所示。
The solution is to cast the address of the floating point variable to a pointer to an int, which is then de-referenced as shown below.
当具有基类的引用或指针,但需要执行不是基类组成部分的派生类操作的时候,需要动态的强制类型转换。
Dynamic casts are needed when we have a reference or pointer to a base class but need to perform operations from the derived class that are not part of the base class.
回忆一下,传递数组或函数类型实参的时候,该实参自动转换为一个指针。
Recall that when we pass an argument of array or function type, that argument is automatically converted to an pointer.
将数组转换为指向数组类型的指针,将函数转换为指向函数类型的适当指针。
An array is converted to a pointer to the type of the array; a function is converted to the appropriate pointer to function type.
任何指针类型可以转换为整数型。
任何指针类型可以转换为整数型。
应用推荐