What is the meaning of the address of a pointer?

前端 未结 4 2123
我寻月下人不归
我寻月下人不归 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:29

    Remember an address on your machine is going to be, itself, a 32 or 64-bit value (depending on your system architecture).

    In your example, you have the integer b that stores the value 10 in some address, let's call it address 500

    Then you have a pointer a, which stores the value 500, and IT has its own address.

    What's the point? You can actually have double-pointers (or more).

    You understand that in

    char* string = "hello";
    

    string is a pointer to the beginning of an array of characters

    Then

    char** strings;
    

    is a pointer to a char*. That's how you could do an array of arrays, for example.

提交回复
热议问题