samedi 16 avril 2022

Do C++ prefer function overload over template? [duplicate]

For example if in this code

void print(int i){
std::cout << "int\n";
}
template < typename T >
void print(T t)
    {
    std::cout<<
    typeid(T).name() << ")" << std::endl;
    }

Now if in main function I do print(1); . Will it always prefer the function over template?

Aucun commentaire:

Enregistrer un commentaire