Add a class variable that increases with every constructor call. Assign this class variable as your own index for the class.
class foo
{
private static int counter;
private int instance_counter;
public Foo()
{
instance_counter = counter;
counter++;
}
public string toString()
{
return "Foo "+instance_counter.toString();
}
}
can't compile out of the box, I don't have a compiler here.
Tobias Langner