Ways to ensure unique instances of a class?
- by Peanut
I'm looking for different ways to ensure that each instance of a given class is a uniquely identifiable instance.
For example, I have a Name class with the field name. Once I have a Name object with name initialised to John Smith I don't want to be able to instantiate a different Name object also with the name as John Smith, or if instantiation…