dimanche 22 avril 2018

Singleton with multi instance management

I'm trying to develop something with let's say :
A class : User
Several instances of User : "john", "joe", ...
I would like that each name is instanced only one time, so if the user tries to create an User wich name already exists, it returns the existing user instance.
With the singleton, I can only make one instance.
How can I do that?

Aucun commentaire:

Enregistrer un commentaire