NULL pointer and void pointer in c ++

Source: Internet
Author: User

NULL pointer and void pointer in c ++
NULL Pointer nullptr previously used 0 or NULL to express NULL pointers:
The NULL macro of C/C ++ is a macro with many potential bugs. Some databases define it as an integer 0, while others define it as (void *) 0. It's okay in the C era. However, in the C ++ era, this will cause many problems.
C ++ 11 uses the nullptr keyword, which is a null pointer with more accurate expression and type security.

# Include

 
  
Using namespace std; int main (){//! Void voidObject; error. The void * pv variable of the void type cannot be declared; // you can declare the void pointer int I = 5; pv = & I; // void type pointer pointing to integer variable int * pint = static_cast

  
   
(Pv); // convert the void pointer to the int pointer cout <"* pint =" <* pint <endl; return 0 ;}

  

 


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.