mardi 20 mars 2018

c++ : Template class , cant figure out the return value of a function

I am trying to implement a single linked list and while doing so i am stuck where i try to return an element from the list. The elements of the list are held in a struct in the class and i am trying to return this struct. Code snippets that descried the situation:

template <class key, class data> class f_sll{ //my class and strcut
     public:
       struct Node{
            key a;
            data b;
            Node* next;  };

 Node getElementAt(int index); // function declaration

Here is the function definition i am having trouble at:

template <class key, class data> typename f_ssl<key,data>::Node f_ssl<key,data>::getElementAt(int index){}  

i am most probably missing something simple but i have looked around a lot and tried a lot of different things. Any help is appreciated.

The error i am getting is: error: expected nested-name-specifier before ‘f_ssl’ so it basically doesnt compile.

Aucun commentaire:

Enregistrer un commentaire