Re: dynamic library and initialisation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sebastien,

Use an class method accessor to guarantee initialization.

class NoGood
{
public:
   static Thingy thing;
};
// Hey, not always initialized!
Thingy NoGood::thing("alpha", "beta");

- - - - -

class ThisWorks
{
public:
  static Thingy& GetThingy();
};
Thingy& ThisWorks::GetThingy()
{
  static Thingy thing("alpha", "beta");
  return thing;
}

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux