C++ Interview Questions

Bjarne-stroustrup
 
Prev1 of 17Next


According to the C++11 standard, what is the output of this program?

template <class T> void f(T &i) { std::cout << 1; }

template <> void f(const int &i) { std::cout << 2; }

int main() {
	int i = 42;
	f(i);
}

Answer