Let's say I have a class:
class Foo {
public:
int a;
}
This class is instantiated via new
operator and destroyed via delete
operator by object B of class Bar.
If object B of class Bar, instantiates new object A of class Foo and then it passes pointer of object A to object of C of class Baz. If Object B of class Bar has been self deleted, then how can object C of class Baz detect if object A is active or it has been deleted. Note: this is on a very small embedded system, therefore no libraries can be used, not even std. See the sequence diagram below.
|------| |------|
| B:Bar| | C:Buz|
|------| |------|
|| |-------| ||
||---New--->| A:Foo | ||
|| |-------| ||
|| || ||
|| || ||
||-----C:Buz.set_foo_Ptr(&A:Foo);----->||
|| || ||
||---Delete--->X ||
|| ||
X (B:Bar Self Deleted) ||
||
(Can C:Buz know if A:Foo
has been deleted or not ?)