简体   繁体   中英

How can I write a definition of function declared in template class returning pointer to struct object?

I have code like this:

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;
}

How proper definition should look like ?

You forgot to add the proper scope to the return type.

Doing that:

template<typename T> typename Foo<T>::Some_struct* Foo<T>::function()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM