Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Feb : Packages and Classes - Question

www.cryer.info
Managed Newsgroup Archive

Packages and Classes - Question

Subject:Packages and Classes - Question
Posted by:"Magnus Eriksson" (no@spam.com)
Date:24 Feb 2005 07:39:44

Hi,

I am a bit confused about packages. Let's say that I have a class called
TAbstractClass (in unit AbstractClass.pas) which has a descendant called
TImplementingClass. I have TImplementingClass in a package. In my main
application i load the package using LoadPackage() and then use it my class
as follows:

  MyClass := TAbstractClass(FindClass('TImplementingClass')).Create;
  MyClass.Run;

This works fine, however I am worried about the fact that both the package
and the main application use the unit AbstractClass. The application has to
use the unit because otherwise I can't create the class and use it. The
package uses the unit since TImplementingClass is a descendant of
TAbstractClass and hence implicitly uses the unit. Won't this result in two
different TAbstractClass VMTs in memory? If not, why? Is there some magic
going on behind the scenes that makes both the package and the application
use the same VMT for TAbstractClass?

Thanks for any clarifications!

- Magnus

Replies:

www.cryer.info
Managed Newsgroup Archive