Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualCornstalks

Posted 28 May 2012 - 09:14 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 (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.

#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.

#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.

#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.

#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.

#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.

PARTNERS