• the nature of pointer

[C++] c pointer

  • const keyword
  1.  const int*  p 
  2.  int const *p 
  3.  int*  const p
  4.     int const a
  5.     const int a

 

 

int a = 3;
int b = 5 ;
int* const p = &a;
*p =10;
//p = &b; error:  address can not be modified , but the content can be modified
const int* p2 = &a;
p2 = &b;
//*p2 = 7; error :  address can  be modified , but the content can not be modified
int const *p3 = &a;
p3 = &b;
//*p3 = 3; error :  address can  be modified , but the content can not be modified
//*p3 = 7; error

相关文章:

  • 2021-04-15
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-10-22
  • 2021-11-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
相关资源
相似解决方案