When should you return a reference to a object from a class method

后端 未结 7 1737
旧时难觅i
旧时难觅i 2021-02-14 01:14

What is the best practice for returning references from class methods. Is it the case that basic types you want to return without a reference whereas class objects you want to r

7条回答
  •  盖世英雄少女心
    2021-02-14 01:50

    if NULL is a possible return value, the method must return a pointer because you can't return a reference to NULL.

提交回复
热议问题