C++ function parameters: use a reference or a pointer (and then dereference)?

后端 未结 11 2213
臣服心动
臣服心动 2021-02-05 10:49

I was given some code in which some of the parameters are pointers, and then the pointers are dereferenced to provide values. I was concerned that the pointer dereferencing wou

11条回答
  •  孤街浪徒
    2021-02-05 11:12

    References are very similar to pointers with one big difference: references can not be NULL. So you no not need to check if they are acutual usable objects (like for pointers).

    Therefore I assume that compilers will produce the same code.

提交回复
热议问题