Inserting objects into BST

I have a class called Shows:
 
  Show(const Date& date, const Time& time, int showNumber, string title, string genre);


I also have a Template BST <T> class and would like to insert shows into it.
1
2
3
4
5
6
 struct node
    {
        T insertItem;
        node *left;
        node *right;
    };


Currently, my insert function works in a simple "check if insert item > or < insert item in node"

1
2
3
4
insert(const T& insertItem, node *Ptr){
...
 if (insertItem < Ptr->insertItem)
}


How can I make it so that the BST checks for example, getShowNumber when inserting Show() into tree?
Last edited on
Line 3 of your snippet implies that Show has overloaded the < operator.
If that's the case, why not put the comparison in the overloaded < operator?
1
2
3
bool Show::operator < (const Show & rhs) const
{  return showNumber < rhs.showNumber;
}



Topic archived. No new replies allowed.