问题
This is my code:
int i = 5;
const int * cpi = &i; //pointer to const
int * pi = cpi; //Error: a value of type "const int*" cannot be assigned to an entity of type "int*"
回答1:
i
is mutable, cause it is not a const type.
You try to store a int address in a const int address via cpi
.
To solve it you have to actually hand over the values not the addresses.
来源:https://stackoverflow.com/questions/34542470/why-this-error-a-value-of-type-const-int-cannot-be-assigned-to-an-entity-of