<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 20/08/2013 02:44, Xiangrong Fang
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAP93jB12eMYimkgS3WAwiKvh=VYeH2NBBEct1ABeBUw0jjJ8aA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div><span style="font-family:courier new,monospace">Hi All,<br>
              <br>
              I am reading this document: <a moz-do-not-send="true"
                href="http://www.freepascal.org/docs-html/ref/refsu29.html">http://www.freepascal.org/docs-html/ref/refsu29.html</a>  
              and doing an experiment with the following code:<br>
              <br>
              program project1;<br>
              {$mode objfpc}{$H+}<br>
              type<br>
                TBase = class<br>
                  constructor Create; virtual;<br>
                end;<br>
                TDerived = class(TBase)<br>
                  constructor Create; override;<br>
                end;<br>
              <br>
              <br>
            </span></div>
        </div>
      </div>
    </blockquote>
    ....<br>
    <blockquote
cite="mid:CAP93jB12eMYimkgS3WAwiKvh=VYeH2NBBEct1ABeBUw0jjJ8aA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><span style="font-family:courier new,monospace">The problem
            is, it makes NO DIFFERENCE at all in the following cases:<br>
            <br>
          </span></div>
        <div><span style="font-family:courier new,monospace">CASE 1:<br>
            <br>
          </span></div>
        <div><span style="font-family:courier new,monospace">TBase.Create;<br>
          </span></div>
        <div><span style="font-family:courier new,monospace">TDerived.Create;<br>
            <br>
          </span></div>
        <div><span style="font-family:courier new,monospace">CASE 2:<br>
            <br>
          </span></div>
        <div><span style="font-family:courier new,monospace">TBase.Create;
            virtual;<br>
          </span></div>
        <div><span style="font-family:courier new,monospace">TDerived.Create;
            virtual;<br>
            <br>
          </span></div>
        <div><span style="font-family:courier new,monospace">CASE 3:<br>
            <br>
          </span></div>
        <div><span style="font-family:courier new,monospace">TBase.Create;
            virtual;<br>
            TDerived.Create; override;<br>
            <br>
          </span></div>
        <div><span style="font-family:courier new,monospace">According
            to the document, "inherited" cannot be used in non-virtual
            methods, and it is wrong to use virtual in sub-class. But my
            test shows the contrary.   BTW, I am running Linux on 64bit
            platform.<br>
            <br>
          </span></div>
        <br>
      </div>
    </blockquote>
    <br>
    Using virtual with constructor makes a difference, if you use "class
    of" types<br>
    <br>
    type <br>
      TBaseClass = class of TBase;<br>
      TDerivedClass = class of TDerived;<br>
    <br>
    Var <br>
      bc: TBaseClass;<br>
    <br>
    begin<br>
      bc:= TBase;<br>
      bc.create;<br>
    <br>
      bc:= TDerived;<br>
      bc.create;  // will call Tderived.create, but only in case 3<br>
    end;<br>
  </body>
</html>