Programming C# C++ (7) Delphi (617) .NET (2) Database (71) Delphi IDE (89) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280) Java (8) JavaScript (31) perl (9) php (4) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us 
|
Testing if two objects are 'related' or 'identical' (RTTI)
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Do you need to know whether object a is of a derived class from the class that another object b is of? Or if they may even be of the same class?
The following little code snippet tells it..  | |  | | program dummy;
var
a,
b: TObject;
begin
if a is b then
ShowMessage('a is derived from b or same class');
if a.classtype=b.classtype then
ShowMessage('a and b are of the same class');
if a.ClassName=b.ClassName then
ShowMessage('a and b are of the same class')
end. | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|