Questions I can not find

Can anyone explain what a lost object is in c++?

The difference between NULL and NIL?

and How does heap management work?


Can anyone explain what a lost object is in c++?
It is an object you do not have any way to refer:
1
2
int* x = new int;
x = nullptr; //Onjct x referred to before is lost 


The difference between NULL and NIL?
NULL is a macro expanding to literal 0; NIL does not exist in standard C++.

so x is considered lost because it holds the value '0'?
No, because it is do not point to object anymore.

Pointer is a treasure map. If you do not get the treasure (properly delete object) and then destroy map (assign null pointer to it) or redraw it (assign another pointer to it), you will never be able to get that treasure (as you do not have a map and have no idea where treasure is)
so NULL/nullptr means the end..no value
there when x = nullptr it means it doesnt exist anymore?
there when x = nullptr it means it doesnt exist anymore?
No, it means that it does not point to anything. Object it was pointing before are bot affected. Pointer is a piece of paper with address on it. You can erase it, rewrite it, do anything with it, but actual building will be unaffected by this.
Okay gotcha,
Earlier what did you mean by macro..when you were defining NULL
Null is defined as #define NULL 0 in the IS
what do you mean by IS?
International Standard
and NIL doesn't exist in standard c++ so where does it exist and what does it do there?
nil exists in other languages, obj-c comes to mind. In obj-c iirc it's an object representing null (in other words it's not simply 0).
Nil is for pseudocode , null or NULL refer to a pointer but you can use nullptr in c++ as well since zero is aldo use for declaring pure virtual methods. How does heap management work, big question.
Topic archived. No new replies allowed.