On Mon, 5 Jun 2006, David Nicolás Abdala wrote:

> >> >> It happens when you try to free an object which either you didn't
> >> >> create, or you've already set free.
> >> >
> >> > Only when the pointer to the object is containin nil. This
> >> is not the
> >> > case if you free an object and also not the case if the variable
> >> > pointing to that object is on the stack and it is not created.
> >> >
> >>
> >> classes declared with the keyword class are never stored on the stack.
> >>
> >
> > I haven't followed your discussion, just mentioning here that
> >
> > X.Free
> >
> > Should never fail since it's a class method and its implementation checks
> > if
> > X is nil. If it's not it calls the destructor of "self" (which is the
> > hidden
> > param each method gets passed to and will be X in this case)
> >
> > Procedure TObject.Free;
> > begin
> >  if self<>nil then
> >   self.Destroy;
> > end;
> >
> 
> I just want to say this again:
> 
> Free is NOT a class method, is a TObject method. Every class has a Free
> method because it is inherited from TObject, but the method is NOT a
> "class method".
> 
> A "class method" is a method you can call for the class (you don't need an
> object to call it) as:
> 
> cant:=TMyClass.getInstancesCount; //wich returns the count of objects
> created of that class
> 
> A class's method is a method that is part of a class (any method not
> defined with the class keyword) as:
> 
> TheObject := TMyClass.Create();
> show := TheObject.ClassName();//wich should return 'TMyClass'
> 
> you can't do:
> 
> TMyClass.ClassName();

Yes you can. ClassName IS a class method.

Michael.

Reply via email to