小编use*_*152的帖子

得到了GCC的"无匹配功能"

为什么这个简单的代码不起作用?

template<class U>
class retype 
{ 
    typedef U type; 
};

class object
{
public:
    template<class U>
    int create(typename retype<U>::type p)
    {
        return 4;
    }
};

int main()
{
    int n = object().create(5);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

在使用GCC进行编译时出现此错误:

test.cpp: In function ‘int main()’:
test.cpp:20: error: no matching function for call to ‘object::create(int)’
Run Code Online (Sandbox Code Playgroud)

问题出在哪儿?

c++ templates

4
推荐指数
1
解决办法
85
查看次数

标签 统计

c++ ×1

templates ×1