singleton question
From: tarmat (tarmat_at_btopenworld.com)
Date: 10/31/03
- Next message: news user: "Re: looking for compilers and/or platforms **without** C++ exception support"
- Previous message: Karl Heinz Buchegger: "Re: UINT cast to int, UINT - variable, help"
- Next in thread: Ralf: "Re: singleton question"
- Reply: Ralf: "Re: singleton question"
- Reply: Tim Clacy: "Re: singleton question"
- Reply: stephan beal: "Re: singleton question"
- Reply: jeffc: "Re: singleton question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 31 Oct 2003 15:30:47 +0530
I have a singleton class that looks a little like this:
class MyClass
{
private:
//data
MyClass()
{
Create();
}
void Create(); //initialization stuff
public:
static MyClass* Instance()
{
static MyClass instance;
return &instance;
}
//interface
};
This singleton class is used within multiple cpp files within my
project. It works fine in debug build but when I compile a release
build the MyClass ctor is called multiple times, one time for each
different cpp file it is called from.
Do you know why this is happening? I don't understand what's going on
at all. Surely it is only possible for the ctor to be called once
given this code.
Thanks for any enlightenment.
- Next message: news user: "Re: looking for compilers and/or platforms **without** C++ exception support"
- Previous message: Karl Heinz Buchegger: "Re: UINT cast to int, UINT - variable, help"
- Next in thread: Ralf: "Re: singleton question"
- Reply: Ralf: "Re: singleton question"
- Reply: Tim Clacy: "Re: singleton question"
- Reply: stephan beal: "Re: singleton question"
- Reply: jeffc: "Re: singleton question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]