Prof. A Olowofoyeku (The African Chief) wrote:
{--- this returns FALSE ---} Writeln (h1 is f2);
That's the interesting case because h1 could (at runtime) be an f2.
If you "Constructed" it earlier with "h1 := f2.create;" instead of "h1 := f1.create;" then "h1 is f2" will also be TRUE. Also, if somewhere down the line you do "h1 := h2;" then "h1 is f2" will also be TRUE
Yes, that's what I mean.
(but you will get an exception when you come to free h1 unless you have overridden the destructor to cater for situations where "h1 is f2".
Doesn't Delphi support virtual destructors? Even BP does...
Interestingly, the compiler does not accept the assignment: "h2 := h1;"
No, and it shouldn't because the types don't match. `h2 := h1 as f2' should work (with the check and possibly an error).
Frank