What is the meaning of the address of a pointer?

前端 未结 4 2173
我寻月下人不归
我寻月下人不归 2021-01-06 13:14

If we have code:

int b = 10;
int* a = &b;
std::cout << a << \" \" << &a << \" \";

As the result, the addres

4条回答
  •  爱一瞬间的悲伤
    2021-01-06 13:34

    Thanks for you all I knew what's wrong with it.

    In fact I created a pointer in memory by int* a = &b; but I thought I didn't so it's my mistake.

    But what I thought that you cannot output the address of something that does not exist in memory like cout<<&(&a),the compiler will tell you that "&" operator need a l-value variable.

    And if you want to output the address of pointer to a, you define a pointer to pointer variable int **p2p=&a, and then you can cout<<&p2p , it works.

提交回复
热议问题