【发布时间】:2011-07-14 07:15:10
【问题描述】:
我有如下 GetContainer() 函数。
template<typename I,typename T,typename Container>
Container& ObjCollection<I,T,Container>::GetContainer()
{
return mContainer;
}
当我如下使用这个方法时
template<typename I,typename T>
T& DynamicObjCollection<I,T>::Insert(T& t)
{
GetContainer().insert(&t);
return t;
}
我遇到了错误。
error: there are no arguments to ‘GetContainer’ that depend on a template parameter,
so a declaration of ‘GetContainer’ must be available
error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of
an undeclared name is deprecated)
它在 MSVC 上运行良好,但 g++ 不是那么宽松。代码有什么问题?
【问题讨论】:
-
您能否发布一个完整的、可编译的示例来演示该问题?