【发布时间】:2011-02-09 16:00:19
【问题描述】:
以下代码在 Xcode 中生成编译错误:
template <typename T>
struct Foo
{
Foo(T Value)
{
}
};
int main()
{
Foo MyFoo(123);
return 0;
}
error: missing template arguments before 'MyFoo'
将Foo MyFoo(123); 更改为Foo<int> MyFoo(123); 可以解决问题,但编译器不应该能够找出适当的数据类型吗?
这是编译器的错误,还是我误解了隐式模板参数?
【问题讨论】:
标签: c++ xcode templates implicit