Posted: Sun May 21, 2006 10:11 pm Post subject: Importing inherited classes
If I have a lot of objects, all of which are interconnected by inheritance, is there any easy way to import them all?
Eg:
code:
class Spell
end Spell
class Projectile
inherit Spell
end Projectile
class Fireball
inherit Projectile
end Fireball
class Explosion
inherit Spell
end Explosion
%... You get the idea
class Unit
import Explosion, Fireball, Spell,...%See Notes below
end Unit
I've tried packaging them all into a module, and then importing that module, but then I get the error:
Quote:
"Fireball" is read-only in this scope and cannot be 'new'ed
(This is in the situation where I have a flexible array of Spells, and I try creating a new element referencing Fireball...)
Sponsor Sponsor
Cervantes
Posted: Mon May 22, 2006 8:11 am Post subject: (No subject)
Just include them all. Don't make them into a Turing unit.
Delos
Posted: Mon May 22, 2006 12:00 pm Post subject: Re: Importing inherited classes
TheOneTrueGod wrote:
Quote:
"Fireball" is read-only in this scope and cannot be 'new'ed
(This is in the situation where I have a flexible array of Spells, and I try creating a new element referencing Fireball...)
IIRC, this error msg is for show only...test it out by creating a new object as you did, then attempting to use it as you regularly would. Methinks it will function quite regularly, despite its apparently uninitialized state.
Otherwise, go with what Cervantes has to say.