<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">Hi,<br>I have <span class="" id="b71348d5-7104-46e5-be31-8f514b4a74bc">objects</span> (classes) derived from base one<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">
<span class="" id="878b43b9-0cdc-4e3d-8bc6-49c2c5e0dd31">TBaseObject</span> = class<span class="" id="c62a6c25-d20c-45fe-b49d-01b3c0b141c9">(</span>TObject)<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">
<span class="" id="c9fe5e5a-d9c0-4cdd-9102-3108bbc3cb37">public</span><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"> constructor Create; virtual;<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">
function Clone:TBaseObject;<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">end;<br><br>TMyObject = class(TBaseObject)<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">
my fields here<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">end;<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">o1, o2:TmyObject;<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">
o1 already created;<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">o2 := o1.Clone;<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">in Clone i want to create new object from TmyObject but in base object in Clone method,like this<br>
<br><span class="" id="878b43b9-0cdc-4e3d-8bc6-49c2c5e0dd31">TBaseObject.Clone:</span><span class="" id="878b43b9-0cdc-4e3d-8bc6-49c2c5e0dd31">TBaseObject;<br></span></div><div class="gmail_default" style="font-family:tahoma,sans-serif">
<span class="" id="878b43b9-0cdc-4e3d-8bc6-49c2c5e0dd31">begin<br></span></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><span class="" id="878b43b9-0cdc-4e3d-8bc6-49c2c5e0dd31"> Result:=</span><span class="" id="878b43b9-0cdc-4e3d-8bc6-49c2c5e0dd31"><span class="" id="878b43b9-0cdc-4e3d-8bc6-49c2c5e0dd31">TBaseObject(</span>ClassType).Create;//I know it is wrong here<br>
</span></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><span class="" id="878b43b9-0cdc-4e3d-8bc6-49c2c5e0dd31">end;<br></span></div><div class="gmail_default" style="font-family:tahoma,sans-serif">
<br clear="all"></div>A<div class="gmail_default" style="font-family:tahoma,sans-serif;display:inline">ny good idea?</div><br><div><span class=""></span>-- <br><div dir="ltr"><span style="font-family:courier new,monospace">I am using last revision of Lazarus, FPC 2.6 on Windows XP SP3<br>
<br>Best Regards<br>Zaher Dirkey</span></div>
<span class=""></span></div></div>