T
Thomas Baier
Hi there,
I've written a list template class and a tree template class. The list class
contains some sort algorithms and I have to sort a list with elements of
type tree<T>*. So I need to compare these elements. I've overloaded the
<,>,<=,>= operators of the tree class, but of course that doesn't work
cause I don't have to compare elements of type tree<T>, but elements of
type tree<T>*. So if I would make
tree<int> a(3);
tree<int> b(4);
cout << a<b;
everything works fine. But I have to do something like
tree<int>* a = new tree<int>(3);
tree<int>* a = new tree<int>(4);
cout << a<b;
I know that this would just compare the adresses of both objects, but I
don't know how to solve that, cause at running time "I" do not know whether
the elements of my list are pointers or not. So I cannot write
*a<*b
cause it could be that a and b aren't pointers.
Is there any way to solve that problem (a way to find out whether there were
pointers or not or something like that)
Thanks for any help
Thomas
I've written a list template class and a tree template class. The list class
contains some sort algorithms and I have to sort a list with elements of
type tree<T>*. So I need to compare these elements. I've overloaded the
<,>,<=,>= operators of the tree class, but of course that doesn't work
cause I don't have to compare elements of type tree<T>, but elements of
type tree<T>*. So if I would make
tree<int> a(3);
tree<int> b(4);
cout << a<b;
everything works fine. But I have to do something like
tree<int>* a = new tree<int>(3);
tree<int>* a = new tree<int>(4);
cout << a<b;
I know that this would just compare the adresses of both objects, but I
don't know how to solve that, cause at running time "I" do not know whether
the elements of my list are pointers or not. So I cannot write
*a<*b
cause it could be that a and b aren't pointers.
Is there any way to solve that problem (a way to find out whether there were
pointers or not or something like that)
Thanks for any help
Thomas