how do i make only 1 object creation of any class?
-
You want to create one instance of a class?WhirlWind– WhirlWind2010-04-04 01:23:54 +00:00Commented Apr 4, 2010 at 1:23
-
to don't create it again. Or do you want to prevent that? ;)RvdK– RvdK2010-04-04 01:24:15 +00:00Commented Apr 4, 2010 at 1:24
-
2You could use the singleton pattern, but this pattern is, a) very difficult to get right, b) almost always used unnecessarily. Why do you want to do this?Marcelo Cantos– Marcelo Cantos2010-04-04 01:52:14 +00:00Commented Apr 4, 2010 at 1:52
-
@Codenotguru: your question title is rather generic. You should edit your question and make it more specific.outis– outis2010-04-04 03:56:43 +00:00Commented Apr 4, 2010 at 3:56
-
Singleton pattern may become evil, there are many points that you should consider, on the surface it is the simplest pattern, but if you dig deeper it is dangerous.baris.aydinoz– baris.aydinoz2010-04-05 09:03:37 +00:00Commented Apr 5, 2010 at 9:03
Add a comment
|
2 Answers
It's known as the Singleton design pattern. There are many tutorials for it, e.g. one here.
Comments
Check out the Singleton Pattern: http://sourcemaking.com/design_patterns/singleton
EDIT: Updated link from C# to C++