exit() call inside a function which should return a reference

前端 未结 4 1550
囚心锁ツ
囚心锁ツ 2020-11-27 08:13

In a library I have a function which searches for a key in a database and return a non-const reference to an object. I want to handle the case in which the key is not found,

4条回答
  •  北海茫月
    2020-11-27 09:00

    A library should never exit the hostest application.

    use "return null", get into an "inconsistent state" whichin to every call you return NULL.
    the library user will have to handle it.

    or exceptions...

提交回复
热议问题