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

前端 未结 1 1912
梦如初夏
梦如初夏 2021-01-19 09:45

This code is so simple, shouldnt it compile? I am really lost with this one.

#include 

template foo(T f)
{
    std::cout &         


        
相关标签:
1条回答
  • 2021-01-19 10:35

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

                         vvvv
    template<typename T> void foo(T f)
    {                    ^^^^
        std::cout << f << std::endl;
    }
    
    0 讨论(0)
提交回复
热议问题