digitalmars.D.learn - Function is not implemented.
- Agustin (19/19) Nov 26 2013 I'm trying to move from Java to D, and i have some like this:
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (21/40) Nov 26 2013 You have to provide the implementations of the interface functions
- Agustin (9/56) Nov 26 2013 Oh i forgot to add the implementation here, but its there, what i
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (14/20) Nov 26 2013 I don't know any other way than implementing in terms of B:
- Jesse Phillips (3/7) Nov 26 2013 Changing protection level like that seems very confusing.I'd
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
Nov 26 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
Nov 26 2013
On Tuesday, 26 November 2013 at 17:50:12 UTC, Ali Çehreli wrote:On 11/26/2013 09:32 AM, Agustin wrote:Oh i forgot to add the implementation here, but its there, what i want to do is with an interface be able to change "protected" to "public", this is possible using Java but i don't know if possible using D. class C : B, A -> setCancelled() is changed from protected to public { }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 implementedYou 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
Nov 26 2013
On 11/26/2013 09:52 AM, Agustin wrote:
Oh i forgot to add the implementation here, but its there, what i want
to do is with an interface be able to change "protected" to "public",
this is possible using Java but i don't know if possible using D.
class C : B, A -> setCancelled() is changed from protected to public
{
}
I don't know any other way than implementing in terms of B:
class C : B, A
{
public override bool isCancelled()
{
return B.isCancelled();
}
protected override void setCancelled(bool value)
{
B.setCancelled(value);
}
}
Ali
Nov 26 2013
On Tuesday, 26 November 2013 at 17:52:28 UTC, Agustin wrote:Oh i forgot to add the implementation here, but its there, what i want to do is with an interface be able to change "protected" to "public", this is possible using Java but i don't know if possible using D.Changing protection level like that seems very confusing.I'd expect a child to be able to expand visibility, not reduce it.
Nov 26 2013









=?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> 