Checking if a variable is initialized

前端 未结 13 1406
后悔当初
后悔当初 2020-12-28 11:59

Seems like this would be a duplicate, but maybe it is just so obvious it hasn\'t been asked...

Is this the proper way of checking if a variable (not pointer) is init

相关标签:
13条回答
  • 2020-12-28 12:31

    There is no way of checking of the contents of a variable are undefined or not. The best thing you can do is to assign a signal/sentinel value (for example in the constructor) to indicate that further initialization will need to be carried out.

    0 讨论(0)
提交回复
热议问题