【发布时间】:2011-12-07 16:19:51
【问题描述】:
当我尝试编译一个简单的 AVL 树程序时遇到这些错误:
no matching function for call to A::max(A*&, A*&)
candidates are: int A::max(A&, A&)
request for member 'levels' in 'b', wich is of non-class type 'A*'
这是导致问题的方法:
void A::simpleLeftRotation(A & tree){
A* b = tree.leftNode;
tree.leftNode = b->RightNode;
b->rightNode = &tree;
tree.levels = 1 + max(tree.leftNode, tree.rightNode); // Problem 1
b.levels = 1 + max(b.rightNode, tree); // Problem 2
tree = b;
}
这是我的班级成员:
A* righNode;
A* leftNode;
int levels;
int element;
行内:
b.levels = 1 + max(b.rightNode, tree);
如果我使用点运算符的 -> insted 我得到:
no matching function for call to A::max(A*&, A&)
candidates are: int A::max(A&, A&)
我不知道我做错了什么。
谢谢。
【问题讨论】:
-
谢谢大家。 Mysticial的回答是最完整的一个
标签: c++ function pointers reference matching