How can i make only one instance of an object ?

Recommended Answers

All 3 Replies

I haven't ever done this but I know it is called a Singleton. I looked it up on wiki and they have an example there. here

Its called a Singleton_pattern

EDIT: oops, should have checked to see if sfuo had the same link or not, sorry.

If you use Codelite IDE and use new class wizard there is Singleton option.
It makes singleton for you and you can learn from there!

It is basically a class utilizing concept of static variable to hold the instance

Check CP example and this Question

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.