Beta D 2.068.1-b2

BBasile via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Fri Sep 4 04:44:42 PDT 2015


On Wednesday, 2 September 2015 at 18:20:49 UTC, Jacob Carlborg 
wrote:
> On 2015-09-02 17:51, Meta wrote:
>
>> Isn't that what `override` is for?
>
> No. Think of it like you want to have a new method with the 
> same name as a method in the base class. It's for hiding a 
> method in the base class, not overriding it. See the C# 
> documentation [1].
>
> [1] https://msdn.microsoft.com/en-us/library/435f1dw2.aspx

What's so different with C# 'new' that not to call 'super' in a D 
overriden method ? (even if C# has itself 'base' instead of 
'super')

C#
---
public class BaseC
{
     public int x;
     public void Invoke() { }
}
public class DerivedC : BaseC
{
     new public void Invoke() { }
}
---

D
---
class BaseC
{
     int x;
     void Invoke() { }
}
class DerivedC : BaseC
{
     override void Invoke() { /*super.Invoke() not called*/ }
}
---

apart from a compiler warning 
(https://msdn.microsoft.com/en-us/library/ms173153.aspx=


More information about the Digitalmars-d-announce mailing list