A reference can not be NULL or it can be NULL?

后端 未结 7 937
忘了有多久
忘了有多久 2020-12-13 16:03

I have read from the Wikipedia that:

“References cannot be null, whereas pointers can; every reference refers to some object, although it may or may n

7条回答
  •  死守一世寂寞
    2020-12-13 16:32

    Well, you can do whatever you want in C++. Another example:

    person &object1 = *( reinterpret_cast(0) );
    

    You are invoking an undefined behavior in the above case, beside the case you mentioned!

提交回复
热议问题