[LC++]Ambiguous error

Peter Poulsen peter_poulsen at stofanet.dk
Tue Nov 25 19:50:02 UTC 2003


I have the following:

class Node { // some stuff };

class Node_Contatainer {
public:
        Node * get_node(unsigned int i) const { return _nodes[i]; }
        Node * get_node(string name) {
                for(unsigned int i = 0; i < _node.size(); i++) {
                        if(_nodes[i]->get_name() == name)
                                return _nodes[i];
                }
                return NULL;
        }
private:
        vector<Node*> _nodes;
}

int main(int argc, char *argv[])
{
        Node_Container *nc = new Node_Container;

        // Load stuff into the container
        nc->get_node(0);

        return 0;
}

If I try to compile this with g++-3.2.3 I something like:

program.cc:15: ISO C++ says that `Node*
  Node_Container::get_node(unsigned int) const' and `Node*
  Node_Container::get_node(std::basic_string<char, std::char_traits<char>,
  std::allocator<char> >)' are ambiguous even though the worst
  conversion for the former is better than the worst conversion for the
  latter

I don't have this problem with g++-2.95.3. Does anybody know what this
means, and more importantly, what I do about it?
-- 
Yours 
Peter Poulsen




More information about the tuxCPProgramming mailing list