How many times the non-template function func will be triggered?
void func(const int& a, const int& b) { }

template <typename T>
void func(const T& a, const T& b) { }

int main() {
    
        func(7.0, 34.0);
        func("cat", "dog");
        func(7, 34);
        func<>(7, 34);
        func<int>(7, 34);
        func('a', 12.5);
    
        return 0;
}
Explanation
Since automatic type conversion for templates is not possible, it is acceptable for ordinary functions, in the latter case, a non-template function is used (both of its parameters are converted to int).

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
C++ quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes