Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Overload Resolution in C++

0 views
Skip to first unread message

zbig...@szymczyk.eu

unread,
Oct 29, 2008, 7:45:46 AM10/29/08
to
Can someone explain me how overload resolution works in C++?

For example if I have function void f(char, int); and I will call
f('A', 3.1) or f(1.5, 3.1F) what would be the result?

Thanks

Victor Bazarov

unread,
Oct 29, 2008, 9:06:13 AM10/29/08
to

If you only have a single function called 'f', no overload is present.
Overload is only there if you have more than one function named 'f':

void f(char, int);
void f(long, double);

int main() {
f(0L, 0.0); // the latter is called
f('c', 42); // the former is called
}

Explaining how overload resolution "works" can take weeks. Please find
a decent C++ book and read the section/chapter on overloading.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

asterisc

unread,
Oct 29, 2008, 2:14:16 PM10/29/08
to
On Oct 29, 3:06 pm, Victor Bazarov <v.Abaza...@comAcast.net> wrote:

Indeed. However, there are some rules that are followed, which are not
that complicated.
Try looking:
http://accu.org/index.php/journals/268

0 new messages