title: C++ virtual function from constructor
body: <p><strong>Why the following example prints "0" and what must change for it to print "1" as I expected ?</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  struct base {
     virtual const int value() const {
        return 0;
     }
     base() {
        std::cout &lt;&lt; value() &lt;&lt; std::endl;
     }
     virtual ~base() {}
  };
  
  struct derived : public base {
     virtual const int value() const {
        return 1;
     }
  };
  
  int main(void) {
     derived example;
  }
  </code></pre>