小编nsa*_*nsa的帖子

为什么这段代码不能用g ++编译

下面给出的示例代码不是用g ++编译的.但它正在开发视觉工作室.是否可以在g ++中的模板类中使用模板成员函数

class Impl
{
public:
        template<class I>
        void Foo(I* i)
        {

        }
};

template<class C>
class D
{
public:
        C c;
        void Bar()
        {
                int t = 0;
                c.Foo<int>(&t);
        }
};

int main()
{
        D<Impl> d;
        d.Bar();
        return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ templates g++

7
推荐指数
1
解决办法
198
查看次数

标签 统计

c++ ×1

g++ ×1

templates ×1