Han777
Programmer
- Dec 12, 2007
- 19
I need to create multiple instances of an object, then keep calling any or all of those instances until no longer needed, at which time any can selectively be destroyed.
I would like to know a programmatic way of creating and calling each instance, naming each incrementally, without knowing ahead of time how many instances may need to be created. For example, when the code detects a condition that requires an instance be created the code would assign an instance to a variable of the same type, then call it by referencing the variable's name.
How can I write code that creates those instances without having to manually create an unknown number variables in the code of the object type I'm needing, as I have no way of knowing how many instances I will be needing to create and call?
I would like to know a programmatic way of creating and calling each instance, naming each incrementally, without knowing ahead of time how many instances may need to be created. For example, when the code detects a condition that requires an instance be created the code would assign an instance to a variable of the same type, then call it by referencing the variable's name.
How can I write code that creates those instances without having to manually create an unknown number variables in the code of the object type I'm needing, as I have no way of knowing how many instances I will be needing to create and call?