C ++ pointer comparison size

Source: Internet
Author: User
 C ++ pointer comparison size 
 the Object Pointer value is an integer mapped to a linear address space, c/C ++ allows comparison between two object pointers of the same type, including = ,! =, <,>, <=,> =. Therefore, the answer to the LZ question is yes. For different types of object pointers, the conversion can be compared. Because the static type check of C ++ is stricter than that of C, the same  Code  may cause compilation errors in the C ++ compiler, while the C compiler generates warnings only due to the lack of implicit conversions. The member pointer of C ++ is generally implemented by offset, but it does not necessarily indicate the specific address or offset (it can be regarded as an invisible struct of a member, and is related to the compiler and the type to which it points; even the sizeof results of different member pointer types on the same compiler are not unique. In this case, the conversion by value cannot be implemented and cannot be compared ), converting to an integer is meaningless. Different Member pointers of different types cannot be compared; operator ==and operator cannot be performed for member pointers of identical types! = Other (arithmetic) Comparison operations. -- 1. the pointer is the memory address. Error. For example, it may indicate the Register address space. 2. the pointer is a 32-bit integer. An error occurs. For example, the pointer value on a 16-bit platform is a 16-bit unsigned integer, And the pointer value on a 64-bit platform is a 64-bit unsigned integer. In addition, the common error is that in C/C ++, the pointer has a type, the address is an integer, and there is no type (in fact, the address is not a concept that should be involved in the language itself ). A pointer can be an object, and the address itself is only a right value. 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.