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.2. equal, mismatch and lexicographical_compare

Figure 16.2 demonstrates comparing sequences of values for equality using algorithms equal, mismatch and lexicographical_compare.

 1   // Fig. 16.2: fig16_02.cpp 2   // Algorithms equal, mismatch and lexicographical_compare. 3   #include <iostream> 4   #include <algorithm> // algorithm definitions 5   #include <array> // array class-template definition 6   #include <iterator> // ostream_iterator 7   using namespace std; 8  9   int main()10   {11      const size_t SIZE = 10;12      array< int, SIZE > a1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };13      array< int, SIZE > a2( a1 ); // initializes a2 with copy of a114      array< int, SIZE > a3 = { 1, 2, 3, 4, 1000, 6

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