Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the SO thread <a href="https://stackoverflow.com/questions/2156634/why-pure-virtual-function-is-initialized-by-0">&ldquo;Why pure virtual function is initialized by 0?&rdquo;</a> Jerry Coffin provided this quote from Bjarne Stroustrup&rsquo;s <a href="http://www2.research.att.com/~bs/dne.html" rel="nofollow noreferrer"><em>The Design &amp; Evolution of C++</em></a>, section §13.2.3, where I've added some emphasis of the part I think is relevant:</p> <blockquote> <p>The curious <code>=0</code> syntax was chosen over the obvious alternative of introducing a new keyword pure or abstract because at the time I saw no chance of getting a new keyword accepted. Had I suggested pure, Release 2.0 would have shipped without abstract classes. Given a choice between a nicer syntax and abstract classes, I chose abstract classes. Rather than risking delay and incurring the certain fights over pure, I used the tradition C and C++ convention of using 0 to represent "not there." The <code>=0</code> syntax fits with <strong>my view that a function body is the initializer for a function</strong> and also with the (simplistic, but usually adequate) view of the set of virtual functions being implemented as a vector of function pointers. [ &hellip; ]</p> </blockquote> <p>So, when choosing the syntax Bjarne was thinking of a function body as a kind of initializer part of the declarator, and <code>=0</code> as an alternate form of initializer, one that indicated &ldquo;no body&rdquo; (or in his words, &ldquo;not there&rdquo;).</p> <p>It stands to reason that one cannot both indicate &ldquo;not there&rdquo; and have a body &ndash; in that conceptual picture.</p> <p>Or, still in that conceptual picture, having two initializers.</p> <p>Now, that's as far as my telepathic powers, google-foo and soft-reasoning goes. I surmise that nobody's been Interested Enough&trade; to formulate a proposal to the committee about having this purely syntactical restriction lifted, and following up with all the work that that entails. Thus it's still that way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload