+ 1

Why we cannot store null into reference in c++?

i want to know why we can not store null in reference ,even though it is a pointer internally.

28th May 2018, 4:43 PM
rushi joshi
rushi joshi - avatar
3 Respuestas
+ 2
if a pointer can store null and if reference acts as a pointer internally then why it cant store null ? i know there is no use of it but still needs to clear my doubts
28th May 2018, 4:54 PM
rushi joshi
rushi joshi - avatar
+ 2
rushi joshi Because the compiler makes sure, at compile-time, that you don't assign a null to a reference.
28th May 2018, 4:59 PM
Vlad Serbu
Vlad Serbu - avatar
+ 1
Why don't you reverse the question? What would be the use of storing null in a reference?
28th May 2018, 4:50 PM
***
*** - avatar