forum-msg-id-135882-edit
Original date:2021-02-21 23:06:09 Edited by: irv Subject: Re: [phix] if 'number' then why not 'list' ?
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 id difficult.)
Not Categorized, Please Help
|