简体   繁体   中英

type does not provide a call operator

I have this function, order , which returns vector<Node*>

vector<Node*> order(vector<string> nodes, vector<pair<string, string>> dependencies) {
             Graph graph = buildGraph(nodes, dependencies);
             vector<Node*> order = buildOrder(graph.getNodes());
             return order;
}

and I call it like this:

vector<Node*> order2 = order(nodes, deps);

However, the compiler gives this error:

error: type 'std::__1::vector<Node *, std::__1::allocator<Node *> >' does not provide a call operator
        vector<Node*> order2 = order(nodes, deps);
                               ^~~~~
1 error generated.

What is going wrong? 'std::__1::vector<Node *, std::__1::allocator<Node *> >' seems to suggest that there is a vector<Node*, <Node*>> or something going on, but I can't seem to figure this out.

It's a bit hard to tell without your posting more complete code, but consider the following:

int order(int j, int k)
{   
    return 3;
}   

int main(int argc, char *argv[])
{   
    char order;

    // order(2, 3);                                                
}

This code builds fine. However, uncommenting

    // order(2, 3);                     

causes it to fail, as within main , order is a character, not a function. From the error message, it looks like you might have some similar problem.

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