且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是超载还是压倒一切?

更新时间:2023-01-23 17:28:25

frontTestSolution中没有被覆盖,它已被重载.

front is not overridden in TestSolution, it is overloaded.

您可以将重载函数视为完全不同的函数,例如名称不同的函数.

You can regard an overloaded function as a completely different function, like one with a different name.

所以t.front(a)会调用Tyre中的那个,而a会隐式转换为long.

So t.front(a) will call the one in Tyre, with an a implicitly converted to long.