Function is not implemented.

Ali Çehreli acehreli at yahoo.com
Tue Nov 26 09:50:11 PST 2013


On 11/26/2013 09:32 AM, Agustin wrote:
> I'm trying to move from Java to D, and i have some like this:
>
> interface A
> {
>    public bool isCancelled();
>    public void setCancelled(bool value);
> }
>
> class B
> {
>    public bool isCancelled();
>    protected void setCancelled(bool value);
> }
>
> But when i do
>
> class C : B, A
> {}
>
> I get
>
> Engine/Main.d(6): Error: class Main.C interface function 'bool
> isCancelled()' is not implemented
> Engine/Main.d(6): Error: class Main.C interface function 'void
> setCancelled(bool value)' is not implemented

You have to provide the implementations of the interface functions 
either in B or C. I think you actually tested with B implementations though:

class B
{
     public bool isCancelled()
     {
         // implemented
         return false;
     }

     protected void setCancelled(bool value)
     {
         // implemented
     }
}

Still the same error...

Unless you want to implement the functions on C as well, then C should 
not inherit from A. A is already inherited by B:

class C : B    // <-- no A
{}

Ali



More information about the Digitalmars-d-learn mailing list