Hi people. I have this question:
I have defined 3 classes, one decsends from another:
type
Class1= class ... end;
Class2= class(Clas1) ... end;
Class3= class(Clas2) ... end;
Next, I have a function like this;
function myFunction(data: Class1): boolean;
begin
if data is Class3 then ....
else if data is Class2 then ...
else if data is Class1 then ...
end.
So, this code doesn't work. Each
is operator returns
false. Why?
The call to the function, in the main program is:
var
d1: class1;
d2: class2;
d3: class3;
begin
d1:= Class1.Create;
d2:= Class2.Create;
d3:= Class3.Create;
myfunction(d1);
myfunction(d2)
myfunction(d3)
...
end.
How can I knows the class type of data on runtime.
Thanks.