Why dont languages allow overloading of methods by return value?

前端 未结 8 662
[愿得一人]
[愿得一人] 2021-01-02 08:38

c, java and many other languages do not pay attention to return values.

int   i = func()
float f = func()
int   func() { return 5 }
float func() { return 1.3         


        
8条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-02 09:13

    Let's say it was allowed, which one would this call:

    func();
    

    That may not the the full answer, but I believe that is one reason why it is not legal.

提交回复
热议问题