为什么更多主流的静态类型语言不支持返回类型的函数/方法重载?我想不出那样做.通过参数类型支持过载似乎没有那么有用或合理.怎么这么不受欢迎呢?
programming-languages overloading language-design function-calls
在方法重载中,是否可以为重载方法设置不同的返回类型?例如,
void foo(int x) ;
int foo(int x,int y);
double foo(String str);
Run Code Online (Sandbox Code Playgroud)
在一般的面向对象编程中,有可能吗?
我有两个接口:
public interface I1
{
A MyProperty { get; set; }
}
public interface I2 : I1
{
new B MyProperty { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在C#中,我可以像这样明确地实现:
public class C : I1, I2
{
public B MyProperty { get; set; }
A I1.MyProperty { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
不知何故,我必须在c ++/cli项目中使用这些接口.那么,我该如何在c ++/cli中实现呢?
提前致谢.