sets and do operations on them

This is a discussion on sets and do operations on them within the C++ Programming forums, part of the General Programming Boards category; I try to take the difference of two sets and record the rest into another set... but it is giving ...

  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,288
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21