开发者

Why cannot c# or c++ differentiate methods based on return type? [duplicate]

开发者 https://www.devze.com 2023-03-09 09:40 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Function overloading by return type?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Function overloading by return type?

If I have two methods:

myClass mc = new myClass();

double d = mc.GetPoint();
int i = mc.GetPoint();

Why cannot the C# or C++ compilers differentiate these functions from their return type? I would have though the return type would be开发者_开发问答 part of the signature of the method, just like any method arguments are.

Why can't the compilers handle this?


C# supports dynamic typing like when you use var. How then is the compiler supposed to know which method it should call?

0

精彩评论

暂无评论...
验证码 换一张
取 消