title: Best way to initialize inline static variable returned by derived class virtual function
body: <p>Originally I had m_damage as a class member in the base class Projectile, assigned the value in the initializer list in each derived class and had a single getter function in the base class.</p>
  
  <p>But then I realized I dont need every instance of the derived classes holding a copy of m_damage since it was the same value for all instances of each derived class, so I needed to make the value <code>static</code> and have each derived class return it in a <code>virtual</code> function override.</p>
  
  <p>After researching online and on here I believe <code>inline static const</code> variable is the way to go. But is there any benefit to having it as a class member or class constant? or is there another better way to do it? I only want the value accessed via the private virtual function in Projectile.</p>
  
  <p>projectile.h file</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class Projectile
  {
  private:
      virtual int getDamage() const = 0;
  }
  </code></pre>
  
  <p>rocket .h file</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class Rocket : public Projectile
  {
  private:
  // inline static const auto ROCKET_DAMAGE = 400;  &lt;---- make it a class member?
      virtual int getDamage() const final override;
  }
  </code></pre>
  
  <p>rocket .cpp file</p>
  
  <pre class="lang-cpp prettyprint-override"><code>// inline static const auto ROCKET_DAMAGE = 400;  &lt;---- make it a class constant?
  
  int Rocket::getDamage() const
  {
      return ROCKET_DAMAGE;
  }
  </code></pre>