How can I instantiate only three instances of an application ?If I open 4th instance, I have to close 1st instance like wise if I open 5th one I have to close 2nd one automatically ?

Questions by mvsrk74

Showing Answers 1 - 6 of 6 Answers

newlife

  • Sep 24th, 2009
 

This can be done using one static variable which will keep account of object and a list which has object reference.
In constructor check if static variable is 4 then remove one object from list and add this new object to the list.

If less then four then just increment the variable and add the object to the list.
Same time in destructor we have to remove the object from list and decrement the static variable bye one.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions