Question on book <Dive into Design Patterns>, Inheritance

Jasper Lai 1 year ago updated by Alexander 1 year ago 1
On page 19, if a superclass implements an interface, all of its subclasses must also implement it

I don't understand it. For example, The below C# sample code I wrote, it has no compile error.
Bird "superclass, implement the Ifly"
Duck "subclass of Bird, but have not implement the Ifly"

Am I mis-understand it?

var duck = new Duck();

interface Ifly
    void Flying(int distance);

abstract class Bird : Ifly
    public void Flying(int distance)
        Console.WriteLine($"I am flying {distance} miles!");

class Duck : Bird

-- Jasper



Sorry for the confusion. I mean that all the subclasses already implement it implicitly if the superclass implements it explicitly. In other words, you can't refuse to have some parts of the original interface in a subclass, it already implements it and you can't change that.