Re: [phix] if 'number' then why not 'list' ?

new topic     » goto parent     » topic index » view thread      » older message » newer message
katsmeow said...

Hmm, ok. Thanks, Irv.

I hate to ask, it seems like an old question, but if i have a mammal class, can a cow class inheret from the mammal class? (speaking about Phix and OE implementations)

Kat

Phix, yes. OE, no.

That's exactly where classes are useful. e.g:

export class Mammal 
  public string gender; 
end class 
 
export class Whale extends Mammal 
end class 
 
export class Cow extends Mammal 
    public integer horns; 
end class 
 
include Cow.e 
 
Cow Bossie = new() 
Cow Ferdinand = new() 
Bossie.gender = "female" 
Ferdinand.horns = 2 
Whale Nemo = new() 
Nemo.gender = "male" 
Nemo.horns = 2 -- no such field (horns) is the error message; 

You'll note that it isn't necessary for your program to specifically include a file declaring the Mammal class. The Cattle file will include that, and look for the "gender" variable in that class (or classes, as the case may be - multiple inheritance is easy to do, the planning part is difficult.)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu