13

If I create this method

public void foo()

And then I create an overloaded version like this

public void foo( string bar )

Do we say that the second functions overloads the first, or are both methods equally "overloaded"?

This would imply (I think), that there is a base type function, that is being overloaded, by another function (somewhat like inheritance, but not really).

Assuming that one method can "overload another", would also imply terms like "overloader" and "overloadie", if that is a word at all. But that doesn't feel right at all, especially since you can have several overloads.

I got to this question when I wanted to write down the process of creating an overloaded method and I wanted the most correct way of writing it down.

Examples:

  • I am overloading foo
  • I am overloading foo with foo( string bar )
  • I am creating an overloaded method
  • I am making foo overloaded

So yeah, this kind of got me thinking, I am not sure what to make of it. There are hundreds, if not thousands, of descriptions of function overloading online, but at a first glance I couldn't find any addressing this.

Null
  • 125

3 Answers3

29

When talking about overloads, the name of the function is overloaded, not the function itself. The functions overloading the name are "overloads" and overload the name, but not each other. In your example, "public void foo()" and "public void foo( string bar )" both overload the name "foo". Therefore, you cannot speak in terms of overloader and overloadee of one of the functions, because they have no direct relationship.

In your examples, you can say that you are overloading "foo" (the name) with "foo( string bar )" (the function), but you cannot say that you create an overloaded method, because methods are never overloaded. You can say that you create an overloading method. To formulate "making foo overloaded" is just a worse way of saying "overload foo".

thiton
  • 5,348
15

I would simply say foo is overloaded. There is certainly no master/slave or parent/child relationship going on here.

DeadMG
  • 36,914
3

I think that a good way to express this is to focus on the final result, not on changes made to the class over time. Thus, instead of saying "I overloaded 'foo' with 'foo(other parameters)'," you say "foo is an overloaded function, with 'foo()' and 'foo(other parameters).'"

mjfgates
  • 2,064
  • 2
  • 13
  • 15