I am using the example below to implement a state design pattern.
I don't wanna delete the *this pointer inside a member class because is not safe (I will call other member function after delete).
void on(Machine *m)
{
m->setCurrent(new ON());
delete this;
}
Is there a better approach to implement the state design pattern? I thought about use Singletons, but I want avoid using singletons.
Best regards,
Aucun commentaire:
Enregistrer un commentaire