template vs. ordinary functions how it is overloaded

D

dalu.gelu

can u let me know if two functions having same name foo(), one is
atemplate function and otherone being ordinary function. if i invoked
the function from main(), which function is to called & why.
thanks
 
C

Carlos Martinez

Ordirary function is called first.
The reason is because standard says:

F1 is preferred over F2 if

"
....
— F1 is a nontemplate
function and F2 is a template function specialization,
....
"

Take a look at ISO/IEC 14882.
13.3.3 Best Viable Function.

Or find it inside the 2003 standard.
 
D

dalu.gelu

thanks Carlos,

but which overloaded template function is called if there are only
template functions having same name & in the form
template<class T> and template<>
 
V

Victor Bazarov

thanks Carlos,

but which overloaded template function is called if there are only
template functions having same name & in the form
template<class T> and template<>

Please quote the relevant portions of the posting you're replying to.

There is a whole chapter (12) in the "C++ Templates" by Vandevoorde
and Josuttis on overloading. Have you got a copy of that book yet?

V
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top