Author: Ido Kanner
99.9% (if not 100%) of the times we are using the Class declaration even when we do
not need it.
Answer:
First of all lets clear what are the diffrences between the two type of
declaration.
Class declaration is actully like the TObject object. There isn't any diffrence
between the 2 declarations:
1 type2 TMyClass1 = class3 {.......}4 end;
5 6 //and the second declaration: 7 8 type9 TMyClass2 = class(TObject)
10 { ....... }11 end;
If you will notice in delphi (in Delphi 3 and above) when you press on CTRL+Space
you will find in the first declaration the same functions like the second
declaration.
And if you will look in the delphi help file, you will find that Class word created
for components !!!!
If you will declare this:
12 type13 TMyObject = object14 { ....... }15 end;
You will not find any function or property inside of it, if you did not declare of
it.
In the Delphi help file, they are writing that the Object declaration can not
receave any properties.
TheObject reserve word is very good for OOP of functions, like let say a CODEC (Encryption and Decryption) of the same thing, we can build it in OOP without the need of a component or a memory allocations (although we can).