O'Reilly logo

C++11 for Programmers, Second Edition by Harvey M. Deitel, Abbey Deitel, Paul J. Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.3.10. Set Operations

Figure 16.10 demonstrates algorithms includes, set_difference, set_intersection, set_symmetric_difference and set_union for manipulating sets of sorted values.

 1   // Fig. 16.10: fig16_10.cpp 2   // Algorithms includes, set_difference, set_intersection, 3   // set_symmetric_difference and set_union. 4   #include <iostream> 5   #include <array> 6   #include <algorithm> // algorithm definitions 7   #include <iterator> // ostream_iterator 8   using namespace std; 9 10   int main()11   {12      const size_t SIZE1 = 10, SIZE2 = 5, SIZE3 = 20;13      array< int, SIZE1 > a1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };14      array< int, SIZE2 > a2 = { 4, 5, 6, 7, 8 };15      array< int, SIZE2 > a3 = { ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required