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 not be valid.”
But I don’t believe because of following code, look at it, compiler gives no error:
class person
{
public:
virtual void setage()=0;
};
int main()
{
person *object=NULL;
person &object1=*object;
}
Please elaborate this point.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…