Why is the dereference operator (*) also used to declare a pointer?

前端 未结 6 880
一向
一向 2021-01-30 12:27

I\'m not sure if this is a proper programming question, but it\'s something that has always bothered me, and I wonder if I\'m the only one.

When initially learning C++,

6条回答
  •  太阳男子
    2021-01-30 13:28

    Haha, I feel your pain, I had the exact same problem.

    I thought a pointer should be declared as &int because it makes sense that a pointer is an address of something.

    After a while I thought for myself, every type in C has to be read backwards, like

    int * const a

    is for me

    a constant something, when dereferenced equals an int. Something that has to be dereferenced, has to be a pointer.

提交回复
热议问题