[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [LC++]Ambiguous error



Try type casting it get_node((unsigned int) 0).
Should solve your problem.


On Tue, 25 Nov 2003 Peter Poulsen wrote :

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


_______________________________________________
This is the Linux C++ Programming List
: http://lists.linux.org.au/listinfo/tuxcpprogramming List