PDA

View Full Version : Object/class?



Ultra
01-03-2003, 02:13 AM
Ok this might be a bad question or good question rigth now I'm to drunk :D (half a bottle of Gin, or something) to know.

What is the difference between:


type
TMyClass = class
SomeInt: Integer;
SomeStr: String:
procedure DoSomething;
{...}


and...


type
TMyObject = object
SomeInt: Integer;
SomeStr: String;
procedure DoSomething;
{...}


I've always used the above and it's just now I've come across the other in an example I downloaded. Is there any significant difference or what?

I probably won't use "object" in many of the programs I'll make but I thought that it might be nice to know the difference between these anyway. (Plus the alternative of asking you guys were to go to sleep and try to drink water in order to not get a hangover tomorrow. Aren't you happy that I came here and shared my thoughts :roll: )

Xorcist
01-03-2003, 05:36 AM
Defining your type as an object gives you the bare bare bare minimum object (i.e. no built-in constructors, destructors, or other methods). Types declared in this manner cannot have published members. Think of this as your nitty gritty object. :x

Defining your type as a class automatically and directly decends from TObject and thus inherits any and all of it's features. This includes default constructors and destructors, class type and instance information, and run-time type information for published members. It basically gives you all the common VCL support you'll need to be productive. :wink:

P.S. Sober up, we don't need ya writing any sloppy code... :)

Ultra
01-03-2003, 12:09 PM
Thanks, I thought it was something similar.

I'm sober now, didn't even get a hangover :D