Why don't I need to check if references are invalid/null?

前端 未结 11 2080
半阙折子戏
半阙折子戏 2020-12-23 11:20

Reading http://www.cprogramming.com/tutorial/references.html, it says:

In general, references should always be valid because you must always initi

11条回答
  •  感情败类
    2020-12-23 11:47

    There is no syntax to check whether reference is valid. You can test pointer for NULL, but there is no valid/invalid test for a reference. Of course, referenced object can be released or overwritten by some buggy code. The same situation is for pointers: if non-NULL pointer points to released object, you cannot test this.

提交回复
热议问题