Often seen it and often used it, wonder if it has a name?
C# version:
public class Register
{
protected Register()
{
Register.registry.Add(this);
}
public static ReadOnlyCollection<Register> Instances
{
get { return new ReadOnlyCollection<Register>(registry); }
}
private static List<Register> registry = new List<Register>();
}
it keeps a track of instances created if you couldn't work it out :)
Edit: it's just a snippet, don't get over excited about GC issues people