我有这样的代码:
template<typename T> class Foo
{
struct Some_struct
{
T object;
Some_struct* next;
};
public:
Some_struct* function(); //declaration of my function
};
template<typename T> Some_struct* Foo<T>::function() //this definition is wrong
{
//something inside
return pointer_to_Some_struct;
}
正确的定义应如何?
答案 0 :(得分:7)
您忘记在返回类型中添加适当的范围。
这样做:
template<typename T> typename Foo<T>::Some_struct* Foo<T>::function()