title: C++ static const members overriding
body: <p>Consider the following.</p>
  <pre><code>struct A {
      static const int X = 1;
      static void printX() {std::cout &lt;&lt; &quot;X &quot; &lt;&lt; X &lt;&lt; std::endl; };
  };
  
  struct B: public A {
      static const int X = 2;
  };
  
  int main(argc argv){
      B b;
      b.printX();
  }
  </code></pre>
  <p>How to force the <code>b.printX()</code> to print value 2?<br />
  Both - constant and method - MUST be static. And therefore, virtual methods are not suitable.</p>
  <p>For anyone who thinks they know my task better than me and wants to see me rethinking it, I'll explain the goal of my efforts :)<br />
  Just imagine class which has behaviour based on set of static constants. The simplest way to implement child class with different set of constants and therefore with different behaviour is derivation of class from previous one with specific set of constant values. It is possible to solve that task using virtual functions. Of cause possible, no question. But this solution will be not very pure in sense of accordance to a theory of modeled entities. Usage of virtual methods in this case will be more a trick than correct implementation.<br />
  For example, IR channels have different timing of pulse durations and package structure. It is convenient to define set of child classes (different IR channel implementations) with a specific set of constant values. That values are static because they are common for every object of class and const because they are needed at compile time only. And because internal implementations of base and child classes are slightly different the best relationship between of them are <code>super class - child class</code>.<br />
  Is it rationale for my original question now?</p>