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
You're missing a return type for foo
. Presumably, you want:
vvvv
template<typename T> void foo(T f)
{ ^^^^
std::cout << f << std::endl;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With