dynamically creating objects only when needed
Posted on 2005-03-26
you might have come across questions like this one. But I tried a lot in the web but came with no answers for my specific problem.
Ok, here is the question:
I have a scenario where I will create objects only when I need it, I will not even initialize it to any random number of objects during the start of the main() function. All I wanted to do is create one new object of some Class X on call to a function. At the same time, the program should also preserve the values of the objects that are creater earier.
To explain more:
I have got a Customer Class with some fields. I donot want to initialize something around 100 customers at the beginning of the program. I want to create one customer at a time when a customer becomes a member of my company. So, there would be times when I need it, but I donot want to initialize at the start.
[Note: I wanted to do the same for Orders and OrderLines]
I think I have reiterated the same thing again but its jus for the sake of comprehension.
Thank you very much for your efforts to help me.