Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • possible duplicate of Initializing private static members Commented Mar 16, 2015 at 8:46
  • You need to initialize outside the class: learncpp.com/cpp-tutorial/811-static-member-variables int Something::s_nValue = 1; Commented Mar 16, 2015 at 8:46
  • Think twice before using static members, unless they are const. Pitfalls you may come across include SIOF, and race conditions. The latter only applies when you or someone else want to do things in parallel with your class. Commented Mar 16, 2015 at 9:00
  • Handling of statics, in particular function-static variables and other statics used for singleton idioms, has improved with C++11. Before, you basically needed to mutex-protect everything yourself, now the compiler helps you. See e.g. stackoverflow.com/questions/11711920/… Commented Mar 16, 2015 at 10:16