about “int const *p” and “const int *p ”

后端 未结 8 2013
無奈伤痛
無奈伤痛 2020-12-09 00:11
#include 
using namespace std;

int main(int argc, char* argv[])
{
    int i1 = 0;
    int i2 = 10;

    const int *p = &i1;
    int const *p2 =          


        
8条回答
  •  醉酒成梦
    2020-12-09 00:54

    int const * p; and const int * p are the same. It is when the const comes after the * that the semantics of the expression change.

    I know, it's crazy.

提交回复
热议问题