Is using NULL references OK?

前端 未结 7 1430
一整个雨季
一整个雨季 2020-12-05 20:37

I came across this code:

void f(const std::string &s);

And then a call:

f( *((std::string*)NULL) );

A

7条回答
  •  被撕碎了的回忆
    2020-12-05 20:51

    Is using NULL references OK?

    No, unless you do not like your boss and your job ;)

    This is something VERY bad. One of most important point of reference that it can't be NULL (unless you force it)

提交回复
热议问题