Thread: sets and do operations on them

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    1

    sets and do operations on them

    I try to take the difference of two sets and record the rest into another set...
    but it is giving me errors
    Code:
    set<int> a,b,c;
    c = set_difference(a.begin(),a.end(),b.begin(),b.end(),c.begin());
    what should I do?

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    That last parameter needs to be std::inserter(c, c.begin()) not c.begin()

    http://www.sgi.com/tech/stl/set.html
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed