4

I am new to C++, but I met an issue:

const int* pp2;
int p2;
pp2 = &p2;

this is right, but the same rule for this code:

const int** pp2;
int* p2;
pp2 = &p2;

this is an error:

error: invalid conversion from ‘int**’ to ‘const int**’ [-fpermissive]

I am confused.
int* can be casted to const int*, but why int** can't be casted const int**?

GingerPlusPlus
  • 5,336
  • 1
  • 29
  • 52
BlackMamba
  • 10,054
  • 7
  • 44
  • 67

0 Answers0