samedi 30 mai 2015

I have created a unordered set, when I am trying to get the constant iterator the compiler is giving error

template Node* LinkedList::findCommonNode_hash(LinkedList* list_2)

{

     unordered_set<Node<T>*>* set = new unordered_set<Node<T>*>();
     Node<T>* curr_list_1 = head->next;
     Node<T>* curr_list_2 = list_2->head->next;
     unordered_set<Node<T>*>::const_iterator itr = set->find(curr_list_1);
     if(itr == set->end())
     {
         set->insert(curr_list_1);
     }
     else
        return curr_list_1;
     unordered_set<Node<T>*>::const_iterator itr1 = set->find(curr_list_2);
     if((itr1 == set->end()))
     {
         set->insert(curr_list_2);
     }
     else
        return curr_list_2;
     return nullptr;

}

IDE: codeblock C++11 . I am getting the below error when trying to get the const_iterator to find the element exist in the set or not.

C:\Education\DataStructure_Algorithms\List\List.cpp|252|error: need 'typename' before 'std::unordered_set*>::const_iterator' because 'std::unordered_set*>' is a dependent scope|

Aucun commentaire:

Enregistrer un commentaire