Jump to content
  • Advertisement
Sign in to follow this  

set operator= not work

This topic is 4254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Works on my machine just fine. Compiles correctly, and functions as one would expect it should, but that is without 'compare' specified. Your problem likely exists in a lack of a proper operator= function contained within 'compare'.

set<char*,compare> t1;
t1 = set<char*,compare>();// <- this line calls the operator= for set,
//which in turn calls operator= for both char* and compare.

set<char*,compare> t2=set<char*,compare>();//compiles into
//set<char*,compare> t2(set<char*,compare>());
//which calls only copy constructors, and no operator=!!!

For the sake of experimentation, try deleting 'compare' from both of your examples, and compile it again.

Of course, since no error message was provided, this is really just an educated guess based on my knowledge of the language, and the real problem could be any number of things that are wrong with the code outside of what is posted here, since 'compare' isn't specified in the posted code.

Oh, and whats with the 10,000 stl topics :P

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!