Overload Resolution in C++

Z

zbigniew

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
 
A

asterisc

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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top