CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
C++ Quiz #121

When the Compiler Cannot Deduce T

mediumTemplates

T appears only in the return type of zero, and the function takes no arguments. Which call compiles?

📄 Code

1#include <iostream>
2 
3template <typename T>
4T zero() {
5 return T{};
6}
7 
8int main() {
9 double d = zero<double>();
10 std::cout << d << "\n";
11 return 0;
12}