When speaking of c/c++ and java what does "overloading" mean?

MacBaine

Banned
Aug 23, 2001
9,999
0
0
It's when you declare two different methods with the same name, using different arguments. The compiler determines which of the two identically named methods to use based on the arguments submitted.
 

edro

Lifer
Apr 5, 2002
24,326
68
91
Yeah, like making the "+" do multiplication or something stupid liek that...
 

beer

Lifer
Jun 27, 2000
11,169
1
0
You can overload functions and operators, based upon the parameters passed to them.

In C, you cannot overload operators. I do believe you can overload functions.

In C++, you can overload operators and fuctions.

You can define a function with the same name, but different parameters. When you call the function, the compiler figures out which function you meant to call, and you can accomplish two different functions with the same function name.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
MacBaine is correct, here's an example:

int myFunction(int a){
return ++a;
}

int myFunction(int a, int b){
return a+b;
}

Two different functions with the same name but different arguments.
 

DT4K

Diamond Member
Jan 21, 2002
6,944
3
81
How many vb programmers do you think started dancing in the streets when they found out they would finally get overloading, inheritance, and all the other OO goodies?
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: Shanti
How many vb programmers do you think started dancing in the streets when they found out they would finally get overloading, inheritance, and all the other OO goodies?

Both of them that actually know enough about programming to know what those things are?