c++ - Getting compilation error while trying to get const_iterator to find the element exist in the set or not -
template <class t> node<t>* linkedlist<t>::findcommonnode_hash(linkedlist<t>* 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 . getting below error when trying const_iterator find element exist in set or not.
c:\education\datastructure_algorithms\list\list.cpp|252| error: need 'typename' before 'std::unordered_set<node<t>*>:: const_iterator' because 'std::unordered_set<node<t>*>' dependent scope|
as error message suggests have add typename keyword because const_iterator dependent name in case.
like this:
typename unordered_set<node<t>*>::const_iterator itr = set->find(curr_list_1); and of course same other similar line.
anyway code doesn't seem make sense, guess that's because it's work in progress.
Comments
Post a Comment