by "Alf P. Steinbach" <alfps@[EMAIL PROTECTED]
>
May 9, 2008 at 12:29 AM
* pleatofthepants:
> I have a maxValue function that is called when I am removing a node
> from my tree.
>
> template <class T>
> T BST<T> :: maxValue (TreeNode<T>* p)
> {
> if (p == NULL) throw ("BAD POINTER");
>
> while (p-> right)
> {
> p = p-> right;
> return *this;
> }
> }
>
> I am getting this error when it compiles: cannot convert BST<int> to
> 'int' in return
> How do I fix this?
How about trying p->value instead of *this?
There's also a problem with the placement of that return statement.
I'll leave it to you to figure it out. ;-)
Cheers, & hth.,
- Alf
PS: Preferentially reserve all uppercase identifiers for macros. It would
also
be a good idea to throw a standard exception object such as
std::runtime_error
instead of anything else. Also, to indicate the exception's origin in the
exception message.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?