title: Call a method of a static member for initialization in C++
body: <p>I have a class that has a static member object. Initializing that static object means setting some of its parameter to a specific value; but this is done by a function from that object. i do not know how to do it if it is static. Any help?</p>
  
  <hr>
  
  <p>To be more specific I have a static boost logger object per class. It has a <code>ClasName</code> attribute and setting this to the <code>name_of_the_class</code> value is done by <code>add_attribute("ClassName", boost::log::attributes::constant&lt;std::string&gt;("MyClass"))</code> function. What is the best way to initialize the static logger? I have done:</p>
  
  <pre><code>typedef boost::log::sources::severity_logger&lt; severity_levels &gt; BoostLogger;
  
  class MyClass
  {
  private:
    static BoostLogger m_logger;
  
  public:
    MyClass()
    {
      MyClass::m_logger.add_attribute("ClassName", boost::log::attributes::constant&lt;std::string&gt;("MyClass"));
    }
  }
  
  BoostLogger MyClass::m_logger; // And here I cannot call the add_attribute() function
  </code></pre>
  
  <p>I know that this is done every time I instantiate the class, so: What is the best way to do it?</p>