0

i'm trying to write a function that returns an iterator to the "node" (object that i've created) which has the correct string identifier (code below):

 list<node>::iterator point_component_from_out(const string out,const list<list<node>>::iterator &row){
        list<node>::iterator it=row->begin(),r_it=row->begin();
        vector<string> vct;
        it++;
        for(it;it!=row->end();it++){
            vct=it->get_outputs_labels();
            for(vector<string>::iterator vct_it=vct.begin();vct_it!=vct.end();vct_it++){
                if(*vct_it==out){
                    r_it=it;
                }
            }
        }
        return r_it;
    }

now i call this function from another function which is in the same .cpp file of the previous one. (little part of the function):

void graph::build_chain(string out,list<list<node>>::iterator row){
    list<node>::iterator it_node,support_it;
    list<list<node>>::iterator new_row;
    string new_out;
    int i=0;
    vector<string> declared_outputs,linked_outputs,declared_inputs,linked_inputs;
    //funzione che ritorna l'iteratore che punta alla porta con quell'out
    it_node=point_component_from_out(out,row);

at this point, when i build the project i get this error from the builder:

undefined reference to `graph::point_component_from_out(std::string, std::_List_iterator<std::list<node, std::allocator<node> > > const&)'

relocation truncated to fit: R_X86_64_PC32 against undefined symbol `graph::point_component_from_out(std::string, std::_List_iterator<std::list<node, std::allocator<node> > > const&)'

if i click on the error it shows me that it refers to the last line of the second code that i've shown you.

  • 5
    From the error you get, I think you forgot `graph::` identifier before your declaration of `point_component_from_out` function – lucie Dec 16 '19 at 14:48
  • Agreed without the `graph::` you implemented a free function `point_component_from_out(const string out,const list>::iterator &row)` not `graph::point_component_from_out(const string out,const list>::iterator &row)`. This looks like a simple typo in your code. If this is not the case please edit your question and correct the typo. – drescherjm Dec 16 '19 at 15:04

1 Answers1

0

If you are writing a realization of point_component_from_out as a function - be sure it is before the graph::build_chain function, if point_component_from_out also a class member and you're writing a realization for method - check if you didn't forget class specifier: MyClass::method.