What will be printed out as a result of the following code execution?
#include <iostream>
#include <map>

template<class T>
void f(std::map<int, T>::value_type& v)
{
    std::cout << v.first << v.second << std::endl;
}

int main()
{
    std::map<int, int> m;
    m[0] = 2;
    f<int>(*m.begin());

    return 0;
}
Explanation
A compilation error will occur in the declaration of the function f. The type name depending on the template parameter must be declared with the typename keyword. Like this:
void f(typename std::map<int, T>::value_type& v)

Follow CodeGalaxy

Mobile Beta

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