On 4-Apr-07, at 3:25 PM, [EMAIL PROTECTED] wrote: > On Apr 04, 2007, at 18:50 UTC, Frank Condello wrote: > >> Example: >> >> Dim c1 As New MySubClass >> Dim c2 As MySubClass >> c2 = MySubClass( c1.Clone ) >> >> If MySubClass is an Object3D that code will run fine, but if the >> super is a home-brewed class that supplies a Clone function you'll >> get a not-so-unexpected illegal cast exception. I can't think of a >> way to do this in RB code - does Object3D use some sort of plugin SDK >> voodoo? > > Yes. Plugins have a way to get a reference to the class of an object, > and then use that to create a new instance of the same class.
That's what I assumed, but it's not immediately obvious how this is accomplished. I don't see any built-in way to get a REALclassRef or class name from a REALobject - but I guess this is a question for the plugin list... > However, I'm not sure I see a real problem -- in your own classes, > define a Clone method to return the base class type. Subclasses > should > override this to return an instance of their class (but still using > the > base class as the return type, else it wouldn't be overriding). The > only thing special about Object3D.Clone is that subclasses don't have > to override Clone to make it work, and in your own hierarchy, they do. I just wanted to avoid constantly overriding things when all the work was done 2, 3, 4, or more classes down the hierarchy. I gave up on returning a new instance a while back and just use sub methods that require an existing instance. In some cases I'll use a cloning- constructor, but that ain't so great for classes that have multiple levels of clone-ability (and multiple clone methods). Either way it's not really a problem, it just feels icky... Thanks, Frank. _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
