title: Static variable inside a constructor, are there any drawbacks or side effects?
body: <p>What I want to do: run some prerequisite code whenever instance of the class is going to be used inside a program. This code will check for requiremts etc. and should be run only once.</p>
  
  <p>I found that this can be achieved using another object as static variable inside a constructor. Here's an example for a better picture:</p>
  
  <pre><code>class Prerequisites
  {
       public:
           Prerequisites() {
                std::cout &lt;&lt; "checking requirements of C, ";
                std::cout &lt;&lt; "registering C in dictionary, etc." &lt;&lt; std::endl;
           }
  };
  
  
  class C
  {
      public:
           C() {
               static Prerequisites prerequisites;
               std::cout &lt;&lt; "normal initialization of C object" &lt;&lt; std::endl;
           }
  };
  </code></pre>
  
  <p>What bothers me is that I haven't seen similar use of static variables so far. Are there any drawbacks or side-effects or am I missing something? Or maybe there is a better solution? Any suggestions are welcome.</p>