This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]