Results 1 to 3 of 3

Thread: Object/class?

  1. #1

    Object/class?

    Ok this might be a bad question or good question rigth now I'm to drunk (half a bottle of Gin, or something) to know.

    What is the difference between:

    [pascal]
    type
    TMyClass = class
    SomeInt: Integer;
    SomeStr: String:
    procedure DoSomething;
    {...}
    [/pascal]

    and...

    [pascal]
    type
    TMyObject = object
    SomeInt: Integer;
    SomeStr: String;
    procedure DoSomething;
    {...}
    [/pascal]

    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: )
    Signature:
    <br />This is a block of text that can be added to posts you make. There is a 255 character limit

  2. #2

    Object/class?

    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.

    P.S. Sober up, we don't need ya writing any sloppy code...
    My DGDev forum pascal syntax highlight settings:
    <br />[background=#FFFFFF][comment=#8080FF][normal=#000080]
    <br />[number=#C00000][reserved=#000000][string=#00C000]

  3. #3

    Object/class?

    Thanks, I thought it was something similar.

    I'm sober now, didn't even get a hangover
    Signature:
    <br />This is a block of text that can be added to posts you make. There is a 255 character limit

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •