暑假我在做一些自学,我遇到了这个我不确定的问题,我想知道是否有人可以帮忙。我不确定最后一个数字,但如果有人愿意检查这些,我会包括我以前的答案。这不是任何课程的作业,我只是想确保在继续前进之前了解自己在做什么。
我正在考虑以下定义:
1. void m (Object o, long x, long y)
2. void m (String s, int x, long y)
3. void m (Object o, int x, long y)
4. void m (String s, long x, int y)
其中这些声明:
Object o;
String v;
int a;
long b;
我正在检查这些电话:
m(v,a,b); Calls 2, because it is the most specific.
m(v,a,a); Not legal, because 2 and 4 could both be called (not specific enough).
m(v,b,a); Calls 4, because it is the most specific.
m(v,b,b); Calls 1, because it is the only one that will fit (long cannot shorten to int).
m(o,b,b); Calls 1, similar reasoning as above answer.
m(o,a,a); Unsure. I'm not sure of the precedence.
提前致谢!