limit number of object that can be created

i want to limit the number of objects that can be created for a class....
like for a class Student i want only two object can be created. as soon as user try to create another object it should flash a error message. and object should not be created.

would be thankful if any one could help out
You could use a static factory pattern. But why would you want this absurd feature? There is most likely a better way to do what you are trying to do.
Last edited on
Topic archived. No new replies allowed.