Re: Singleton instantiated more than once with -fvisibility=hidden

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

 



On Friday 03 June 2005 14:22, Mws wrote:
> template<class IMPLEMENTINGCLASS>
> class TSingleton
> {
>         private:
>                 static IMPLEMENTINGCLASS* instance;
>
>         public:
>                 static IMPLEMENTINGCLASS* getInstance()
>                 {
>                         //debugging purposes
>                         std::cout << "before" << instance << std::endl;
>                         if(!instance)
>                         {
>                                 instance = new IMPLEMENTINGCLASS();
>                         }
>                         std::cout << "after" << instance << std::endl;
>                         return instance;
>                 }
>
>                 void dispose()
>                 {
>                         if(instance)
>                         {
>                                 delete instance;
>                                 instance = NULL;
>                         }
>                 }
> };
>
> template<class IMPLEMENTINGCLASS> IMPLEMENTINGCLASS*
> TSingleton<IMPLEMENTINGCLASS>::instance = NULL;

But I still have more then one instance:

before0
my_singleton::my_singleton()
after0x804a008
before0
my_singleton::my_singleton()
after0x804a018

-- 
Filipe Sousa

Attachment: pgpWA1075cr0A.pgp
Description: PGP signature


[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