troubleshooting Question

Can't add custom objects to a set

Avatar of MBarongan
MBaronganFlag for United States of America asked on
Programming Languages-OtherC++
6 Comments1 Solution422 ViewsLast Modified:
I have a custom class named videoType. I'm trying to add several videoType objects to a set named videoSet like this:

  set<videoType> videoSet;  
  videoType video1("Titanic", 1);
  videoType video2("Star Wars", 2);

When I try to add video1 to the set, I get an error message that points to this line of code in the stl_functions.h file:

/// One of the @link comparison_functors comparison functors@endlink.
  template<typename _Tp>
    struct less : public binary_function<_Tp, _Tp, bool>
      operator()(const _Tp& __x, const _Tp& __y) const
      { return __x < __y; }

I overloaded all the comparison operators in the videoType class so that the videoType objects can be sorted. Is there something else I need to do to enable the objects to be inserted into the set?

Attached are my files.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros