
On Thursday 05 April 2007, Kevin Yuan wrote:
2007/4/4, Martin Bonner <Martin.Bonner@pi-shurlok.com>: Static variable in an inline function.
Am I missing something or static variables in inline functions are considered BAD PRACTICE?
Yes, I agree. Something like:
// st.h class st { private: st(){} public: static st* get_instance() { static st* inst = new st; return inst; } };
IIRC if get_instance() will be inlined and 2 translation units will have their own copy of get_instance() then there will be two st instances in the finall app... witch in case of a singleton is BAD. ps: i only had 2 zips of coffee so i might be missing something ... -- Best Regards, Iulian Margarintescu http://www.erata.net eti@erata.net (spamassassin & pf & spamd all said it's OK to make it public ;-) ) Key ID: 0x03176E5CEDEFF7AB I prefer plain text email