Results 1 to 9 of 9

Thread: Weird error

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    You welcome, the natural way to instantiate, use and release a class, is like this
    Code:
    type
       tmyclass = class
       public
          constructor create;
       end;
    
    var
       myclass: tmyclass;
    
    begin
       myclass:= tmyclass.create;
       //
       //  some processing...
       //
       myclass.free;
    end.
    As you can see, I didn't declare a free destructor, it is implicitly inherited from tobject class. If you want to inherite some other class you must specify it when creating it, like this:
    Code:
    type
       tmyclass = class(tcomponent)
       public
          constructor create;
       end;
    constructor and destructor are methods, just like any procedure, but have a fancy name and special purpouse. Inside them you must put your initialization and finalization code for the class. Of course you can inherite your own classes.
    Hope this bring you some light. Happy codding!
    Last edited by pitfiend; 22-03-2014 at 07:59 PM.

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
  •