This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: G++ and constructors
- From: John Love-Jensen <eljay at adobe dot com>
- To: Sean MacLennan <seanm at seanm dot ca>, MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Tue, 06 Mar 2007 06:46:31 -0600
- Subject: Re: G++ and constructors
Note:
I put in the init_instance() presuming you wanted to do some extra work in
there -- such as whatever lock() and unlock() are doing.
If you don't need to do any extra work, then you can collapse it to the
simpler:
----------------------------------------------------------------------
myclass* myclass::get_instance() // public: static
{
static myclass* instance = new myclass;
return instance;
}
----------------------------------------------------------------------
Sorry if I previous more complicated example caused confusion.
--Eljay