-
Notifications
You must be signed in to change notification settings - Fork 75
Description
A final comment for today (I was curious how you solved this C# feature):
Given the following C# file:using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;namespace ch.fhnw.imvs
{
class B {
public virtual void foo() {
Console.WriteLine("B:foo");
}
}
class D : B {
public new void foo() {
Console.WriteLine("D:foo");
}
}public class Test5 {
public static void Main(){
B b = new D();
b.foo();
Console.WriteLine("Done");
}
}
/*
Output:
B:foo
*/
}Executing this program generates the output B:foo. If I run the generated Java program (the generated code is attached), then the output is D:foo. Has to do with the "new" modifier I used in class D.
I do not yet know how that problem could be solved in Java.
Yes, we naively assume all methods are virtual as in Java. I will
have a think about how we can improve this. And, in the meantime I
will add warnings where the new modifier is used.
Thanks again for your feedback.