Question on shapes

Ali Çehreli acehreli at yahoo.com
Tue May 17 06:08:49 UTC 2022


On 5/16/22 22:08, matheus wrote:

 > interface Shape {
 >    void draw();
 >    void draw(float scale);
 > }

Interfaces can have 'final' functions:

interface Shape {
   void draw(float scale);

   final void draw() {
     draw(1);
   }
}

Obviously, for that to work, now Circle.draw() etc. required to respond 
to a 'scale' parameter.

 > In D there would be a better way to do such thing?

Reminding that class hierarchies can be deeper as well:

interface A {                        }
class B : A {          void foo() {} }
class C : B { override void foo() {} }

Ali



More information about the Digitalmars-d-learn mailing list