Reputation: 1590
This code is so simple, shouldnt it compile? I am really lost with this one.
#include <iostream>
template<typename T> foo(T f)
{
std::cout << f << std::endl;
}
int main()
{
foo(3);
return 0;
}
Error:
main.cpp(6): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Upvotes: 4
Views: 5205
Reputation: 61920
You're missing a return type for foo
. Presumably, you want:
vvvv
template<typename T> void foo(T f)
{ ^^^^
std::cout << f << std::endl;
}
Upvotes: 10