Can Singleton Classes be "truly indestructible"?

When I say truly indestructible, I'm referring to the class object not getting destroyed until the machine is turned off. Is this true?

I read in a Stack Overflow post, that there are "2 varieties of singletons with respect to destructibility:

1) Destructible (They die when the application does)
2) Indestructible (They die when the machine does)"

I'm having trouble understanding how an object stays alive even when the application is shutdown.

This is an example of a singleton class design pattern I use all the time, I got it from an SDL book:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class UI {
public:
    static UI *Instance() {
        if (m_instance == 0) {
            m_instance = new UI();
            return m_instance;
        }
        return m_instance;
    }
private:
    static UI *m_instance;
    UI(){};
    ~UI(){};
};


source: http://stackoverflow.com/a/15733545
Last edited on
When I say truly indestructible, I'm referring to the class object not getting destroyed until the machine is turned off. Is this true?

No.
Thanks cire, that's what I thought. Not sure where the poster from Stack Overflow got that idea.
but then there should be a way to create a truly indestructible stuff?
I believe you're misunderstanding how programs are developed. Basically you want to make it a background process which is always running, started upon boot.
Topic archived. No new replies allowed.