Original Post
I was wondering, is there any risk in having an instance of a class calling a function that will delete that instance? In other words: Do methods stay on the function stack even if in the middle of that method's execution its class instance is deleted? I haven't run into any problems yet, but I just want to be sure. Here's what I mean, in C++:
namespace App
{
void popState()
{
// currentState points to an instance of B_State.
delete currentState;
currentState = stateStack.top();
}
}
class B_State : public State
{
public:
void update()
{
App::popState();
}
}