<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">Le 20/08/2013 07:34, Xiangrong Fang a
écrit :<br>
</div>
<blockquote
cite="mid:CAP93jB2_=90HH1Co6RbES_wT+67neReqk3tdrqpMdv1tcdihCQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Hi Flavio,<br>
<br>
</div>
<div>Your findings confirmed mine, but not telling me why? It
seems that the "virtual" keyword has no use at all! To
confirm this, I just removed the "inherited" call in TDerived,
then re-run the program with or without "virtual/override",
the result is exactly same, i.e. with c2 (declared as TBase),
the following statements ALWAYS calls constructor of TDerived,
NOT TBase:<br>
<br>
</div>
<div>c2 := TDerived.Create;<br>
</div>
<div>c2 := TBase(TDerived.Create);<br>
<br>
</div>
<div>This is not same as the description in: <a
moz-do-not-send="true"
href="http://www.freepascal.org/docs-html/ref/refsu26.html">http://www.freepascal.org/docs-html/ref/refsu26.html</a><br>
<br>
</div>
<div>BTW, the above documents are talking about objects, but I
am using classes, is there any difference here?<br>
</div>
</div>
</blockquote>
Yep: a class is a construct definig a collection of variables,
properties and methods whilst an object is an instantiated class.<br>
<br>
TMyClass = class(TSomething) <<-------- this is a
class<br>
public<br>
constructor Create;<br>
blabla<br>
end;<br>
<br>
var<br>
obj: TMyClass ; <<----------- this is a declared
oblect which instantiates a class when created (see next line)<br>
...<br>
Obj := TMyClass .Create; <<----- now the class
TMyClass exists thru the Obj object<br>
<br>
In other words, a class is non existent whilst an object falls into
the real world. A class describes, an object makes use of a class<br>
A class is unique bet there can be lots of objects instantiating a
class<br>
These few words help to explain the basic difference even if some
more technical explations couls be needed. AFAIK, all OOP languages
use almost the same terminology<br>
<br>
This is why class procedures and functions exist. But this is
another story.<br>
<br>
Antonio.<br>
<blockquote
cite="mid:CAP93jB2_=90HH1Co6RbES_wT+67neReqk3tdrqpMdv1tcdihCQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>Shannon<br>
</div>
</div>
<br>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<table
style="font-family:'Calibri','sans-serif';font-size:8.0pt;color:#002f87;border:0;width:auto;">
<tbody>
<tr>
<td style="vertical-align:bottom;padding:40px 20px
25px;border-top:1pt solid #BFBFBF;"> <img alt="Sita
Software"
src="cid:part2.03040805.00060806@sitasoftware.lu"> </td>
</tr>
<tr>
<td style="vertical-align: top; padding: 5px 20px 0;"> <b>Antonio
Fortuny</b><br>
Senior Software engineer<br>
<br>
220, avenue de la Liberté<br>
L-4602 Niederkorn<br>
Tel.: +352 58 00 93 - 93<br>
<a style="color:#002f87;cursor:pointer;text-decoration:
none;" href="http://www.sitasoftware.lu">www.sitasoftware.lu</a><br>
</td>
</tr>
<tr>
<td style="padding:20px 20px 30px;border-bottom: 1pt solid
#BFBFBF;" align="right"> <img alt="Your IT Partner"
src="cid:part4.06090504.09020004@sitasoftware.lu"> </td>
</tr>
</tbody>
</table>
</div>
</body>
</html>