3 /* This is C<<1 rewrite of object polymorphism from
4 http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming
6 Of course there are easier ways to do the same thing... :-)
11 str
method(talk
) (anonymous self
);
20 construct(Animal
) (Animal self
, str name
)
26 str
cat_talk(anonymous self
)
31 str
dog_talk(anonymous self
)
36 Actions
cat_actions(void)
38 Get_mem(this,Actions
);
40 this->talk
= cat_talk
;
44 Actions
dog_actions(void)
46 Get_mem(this,Actions
);
48 this->talk
= dog_talk
;
56 Actions cat
= cat_actions();
57 Actions dog
= dog_actions();
59 animal
[0] = get_obj(Animal
,cat
,"Missy");
60 animal
[1] = get_obj(Animal
,cat
,"Mr. Bojangles");
61 animal
[2] = get_obj(Animal
,dog
,"Lassie");
65 print(animal
[i
]->name
,":",_(talk
,animal
[i
]));
This page took 0.284555 seconds and 4 git commands to generate.