Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface IAnimal {
- void Bark();
- void Eat(Food food);
- }
- interface IBrainy {
- void Act();
- }
- class Dog : IAnimal Animal, IBrainy Brain {
- void as Animal.Bark(), Brain.Act {
- // Bark
- }
- void as Animal.Eat(Food food) {
- // Eat
- }
- }
- // Example of inheriting classes
- class TalkingDog : Dog Dog, IBrainy TalkingBrain {
- void as TalkingBrain.Act() {
- // Talk
- }
- }
- /**** Invocation example ****/
- var dog = new Dog();
- dog.Act(); // obvious single implementation
- var talkingDog = new TalkingDog();
- talkingDog[TalkingBrain].Act(); // call the TalkingBrain implementation
- // Getting a specific implementation is recursive, as via multi inheritance you can implement a method twice in both parent classes, thus requiring double implementation specification
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement