Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Importing inherited classes
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheOneTrueGod




PostPosted: 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
Sponsor
sponsor
Cervantes




PostPosted: Mon May 22, 2006 8:11 am   Post subject: (No subject)

Just include them all. Don't make them into a Turing unit.
Delos




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: