An object a
of class A
calls an object b
of class B
, through a pointer:
void A::fun(){
bPtr->delete_me();
}
In the called function we delete the calling object through a pointer (which was stored earlier):
void B::delete_me(){
delete aPtr;
}
Is this safe, given that A
does not access any of its members after calling bPtr->delete_me();
?