int getTreeNodeCount() const is marked as const (i.e. it guarantees it won't modify the object). It attempts to call int nodeCount(DListNode<T>& node), which is not marked as const, and therefore cannot guarantee the object isn't modified (thus it tries to convert a const this to a non-const this) (int getTreeHeight() const also has this problem, and other functions may too, which I don't have time to validate). If getTreeNodeCount() is to remain const, nodeCount(DListNode<T>& node) needs to be marked as const (and should probably take a const DListNode<T>&, or rather it should probably take a const DListNode<T>*).
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
And there's no reason int height(DListNode<T>* &p) should take a reference to a pointer. Just taking a pointer would suffice.
Show differencesHistory of post edits
#5Cornstalks
Posted 28 May 2012 - 09:07 PM
int getTreeNodeCount() const is marked as const (i.e. it guarantees it won't modify the object). It attempts to call int nodeCount(DListNode<T>& node), which is not marked as const, and therefore cannot guarantee the object isn't modified (int getTreeHeight() const also has this problem, and other functions may too, which I don't have time to validate). If getTreeNodeCount() is to remain const, nodeCount(DListNode<T>& node) needs to be marked as const (and should probably take a const DListNode<T>&, or rather it should probably take a const DListNode<T>*).
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
And there's no reason int height(DListNode<T>* &p) should take a reference to a pointer. Just taking a pointer would suffice.
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
And there's no reason int height(DListNode<T>* &p) should take a reference to a pointer. Just taking a pointer would suffice.
#4Cornstalks
Posted 28 May 2012 - 09:05 PM
int getTreeNodeCount() const is marked as const (i.e. it guarantees it won't modify the object). It attempts to call int nodeCount(DListNode<T>& node), which is not marked as const, and therefore cannot guarantee the object isn't modified (int getTreeHeight() const also has this problem, and other functions may too, which I don't have time to validate). If getTreeNodeCount() is to remain const, nodeCount(DListNode<T>& node) needs to be marked as const (and should probably take a const DListNode<T>&).
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
And there's no reason int height(DListNode<T>* &p) should take a reference to a pointer. Just taking a pointer would suffice.
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
And there's no reason int height(DListNode<T>* &p) should take a reference to a pointer. Just taking a pointer would suffice.
#3Cornstalks
Posted 28 May 2012 - 09:02 PM
int getTreeNodeCount() const is marked as const (i.e. it guarantees it won't modify the object). It attempts to call int nodeCount(DListNode<T>& node), which is not marked as const, and therefore cannot guarantee the object isn't modified. If getTreeNodeCount() is to remain const, nodeCount(DListNode<T>& node) needs to be marked as const (and should probably take a const DListNode<T>&).
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
#2Cornstalks
Posted 28 May 2012 - 09:02 PM
int getTreeNodeCount() const is marked as const (i.e. it guarantees it won't modify the object). It attempts to call int nodeCount(DListNode<T>& node), which is not marked as const, and therefore cannot guarantee the object isn't modified. If getTreeNodeCount() is to remain const, nodeCount(DListNode<T>& node) needs to be marked as const (and should probably take a const DListNode<T>&).
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
#1Cornstalks
Posted 28 May 2012 - 09:01 PM
int getTreeNodeCount() const is marked as const (i.e. it guarantees it won't modify the object). It attempts to call int nodeCount(DListNode<T>& node), which is not marked as const, and therefore cannot guarantee the object isn't modified. If getTreeNodeCount() is to remain const, nodeCount(DListNode<T>& node) needs to be marked as const (and should probably take a const DListNode<T>&).
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.
Also, note that nodeCount() takes a DListNode<T>&, but rootNode is a DListNode<T>*. They're not the same thing.
But that error doesn't match the file you posted. It says the error is on line 66 and is with BinaryTree<T>::height, but line 66 is int getTreeNodeCount() const.