Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"C4430: missing type specifier - int assumed" in a template function

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
like image 666
TheVTM Avatar asked Dec 26 '22 03:12

TheVTM


1 Answers

You're missing a return type for foo. Presumably, you want:

                     vvvv
template<typename T> void foo(T f)
{                    ^^^^
    std::cout << f << std::endl;
}
like image 132
chris Avatar answered Dec 28 '22 16:12

chris