December 2001
Beginner
976 pages
22h 4m
English
There are cases when a class needs to achieve the same task starting with different input values—that is, with different arguments. You have seen examples of this behavior when you learned about constructors. The same rules apply to regular method overloading. The overloading of regular methods is less common than the constructor overloading, which is used in almost every class. A class that models a calculator could have a method called Add that can be overloaded to take different types of numeric values (Short, Integer, Long, and so on).
Public Class Calculator Public Overloads Function Add(ByVal x As Short, ByVal y As Short) As Long Return x + y End Function Public Overloads Function Add(ByVal x As Integer, ByVal y As Integer) ...
Read now
Unlock full access