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

前端 未结 6 881
一向
一向 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:19

    That is a language decision that predates C++, as C++ inherited it from C. I once heard that the motivation was that the declaration and the use would be equivalent, that is, given a declaration int *p; the expression *p is of type int in the same way that with int i; the expression i is of type int.

提交回复
热议问题