When pass-by-pointer is preferred to pass-by-reference in C++?

前端 未结 13 1445
南笙
南笙 2020-12-02 18:46

I can imagine one case, in which the input parameter could be NULL so that pass-by-pointer is preferred but not pass-by-reference?

Can anybody add more cases?

13条回答
  •  清歌不尽
    2020-12-02 19:07

    A function could, conceivably, be written to do something with the memory, such as reallocating it to make it larger (returning the new pointer).

提交回复
热议问题