                                                       ++   83

                                         II

                                       

      ,   ,   
    .  -   
 ,    0,  1.    
  , ,  ,   ,  .
    ,   - :

    00011011011100010110010000111011 ...

        ,    
     (   
     ). ++ 
      . (      4.)
    ,     - ,
     .   8 ,   - 4 ,  32 .
         . 
   64- ,      
 16- .        ,
       -.
       ,   .

                       

                               1.

      , ,     1040      1024
 ,     1032      1040.
      ,     - , - 
.       8 ?    
    ( ,    ), 
   ,   .
   ++     : , ,
 -      : , , 
.  ,        
: ,    .   
, ,  .    ++   
,       .   
 ++     ,   
 II  .
    3      ,   , 
     .   , , 
,    2.3.   4  ,
    ,  .   5 
  .    6    ++ 
  -    .

                                                       ++   84

                             3.   ++

        ,  ,  
 ++.     , ,  3.14159  pi, 
   ,  ,    
   .     
   .  ,   
    ,    ++.
     ,     
   ++,        
 .        
 ++.

                                  3.1. 

    ++         
 , ,      , 
    .  char    
    .     .  short,
int  long     .   
  ,    ,   
    .  short  
 , int   , long     .  32- 
int  long,  ,  .
    float, double  long double       
   (  )  .
 float ( )    , double (
)  ,  long double ( )  .
    char, short, int  long    , ,   , 
  (signed)   (unsigned).     
     (0  , 1  ),    
.        . 8- 
signed char     -128  127,  unsigned char   0 
255.
        ,  1,    
,   . ,     
  ,  ,       
.    :   , ,
   ,      .  
  . , 0   int, 3.14159   double.
         ,  
 .     20,  ,
   :

     20 // 
    024 // 
   014 // 

                                                                 ++   85

       0,    ,   0  0,  
.      .
          signed int.   
     long,      L ( 
 L,    l,       
:     1).  U ( u)     
unsigned int,     UL  LU    unsigned long. :

   128u 1024UL 1L 8Lu

   ,   ,     
 ,     () .   
  double.     float    F 
f,   long double - L  l,        .
:

   3.14159F   0/1f     12.345L  0.0
   3el        1.0E-3E    2.     1.0L

    true  false    bool.
          
 . :

   'a' '2' ',' ' ' ()

     (,  )   escape-
 .     ( 
    ):

     			\n
     	\t
    				\b
     	\v
     		\r
     			\f
    				\a
      	\\
    				\?
     		\'
     		\"

   escape-     \ooo,  ooo     
 .     .  ASCII-,  
  :

   \7 () \14 ( )
   \0 (null) \062 ('2')

                                                                 ++   86

        L (, L'a'),  
  wchar_t    ,   
   ,      
  char, , ,    .
       ,    .  
    ,         
.       escape-
.    :

   "" ( )
   "a"
   "\nCC\toptions\tfile.[cC]\n"
   "a multi-line \
   string literal signals its \
   continuation with a backslash"

          ,  
    ++      
  0 (\0).
    'A'    ,    ""    
: ''  \0 ( ).
      wchar_t,     , ,   
   ,  L:

   L"a wide string literal"

      wchar_t       , 
.
              ( char
 wchar_t),      . ,  

   "two" "some"

      twosome    .
         .  :

   // this is not a good idea
   "two" L"some"

  -      ,   
    . ,   
      ,  . 
     .

                                           3.1

     :

                                                               ++   87

   (a) 'a', L'a', "a", L"a"
   (b) 10, 10u, 10L, 10uL, 012, 0*C
   (c) 3.14, 3.14f, 3.14L

                                       3.2

         ?

   (a) "Who goes with F\144rgus?\014"
   (b) 3.14e1L
   (c) "two" L"some"
   (d) 1024f
   (e) 3.14UL
   (f) "multiple line
        comment"

                                   3.2. 

    ,      2   10. :

   #include <iostream>

   int main() {
      // a first solution
      cout << "2 raised to the power of 10: ";
      cout << 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2;
      cout << endl;
      return 0;
   }

    ,      ,   10 
  2.        
,       1024.
        2  17 ,    23.  
    ! ,   ,  
,      ...   ,  
     0  15? 16    , 
 :

   cout << "2   X\t";
   cout << 2 * ... * 2;

     1,      
?
   ,    .       ,
  .      
 ,  ,  :     
 ,    .      
    .

                                                            ++   88

           ,     
    !   ,    , 
     .
          ,  , 
   .  ,    
,    .      
  ,       
 ,     ,     
 .    !      
.
           
.        
,      .  ,  
    .     :

   #include <iostream>
   int main()
   {
     // objects of type int
     int value = 2;
     int pow = 10;
     cout << value << "   "
          << pow << ": \t";
     int res = 1;
     //  :
     //   res
     //     cnt    pow
     for ( int cnt=1; cnt <= pow; ++cnt )
        res = res * value;
     cout << res << endl;
   }      

value, pow, res  cnt   ,   ,  
 .   for     pow
.
   ,      .     
.    ,     
    ,     , 
   .

   int pow( int val, int exp )
   {
     for ( int res = 1; exp > 0; --exp )
        res = res * val;
     return res;
  }
                                                             ++   89

            .  
          0  15:

   #include <iostream>
   extern int pow(int,int);

   int main()
   {
     int val = 2;
     int exp = 15;
     cout << " 2\n";
     for ( int cnt=0; cnt <= exp; ++cnt )
        cout << cnt << ": "
             << pow( val, cnt ) << endl;
     return 0;
  }

   ,   pow()       .
     ,    
     1.     
        int,   
    . ,  ,
,  ,    ?  ,
   ,     .

                           3.2.1.   

   ,       ,     
 ;        .  
++   ,      
 ,  ,    ,   ,
   .       :

   int student_count;
   double salary;
   bool on_loan;
  strins street_address;
   char delimiter;

   ,   ,         
 .       .  
  :

     ,  r- ( read value    ),
              ,  
     ;
      ,   ,  l-
     ( location value   )  ,   r-
    ;   .

                                                               ++   90

    

   ch = ch - '0';

 ch         . 
    (ch    '0'):  
      .   
:   ,    ch,  
.          l-
.      :

   //  :     l-
   // :  -  l-
   0 = 1;
   // :   -  l-
   salary + salary * 0.10 = new_salary;

         .   
      ,     
   .   ,     ,
    ,  . :

   //  module0.C
   //   fileName
   string fileName;
   // ...  fileName 

   //  module1.C
   //   fileName

   // ,  :
   // fileName    module1.C
   ifstream input_file( fileName );

   ++ ,         .  
       
 .     module1.C   , 
 fileName    .    ,  
      fileName.   
   :

   //  module1.C
   //   fileName
   
   // fileName ,    
   //        
   extern string fileName;
                                                            ++   91

   ifstream input_file( fileName )

      ,     , 
 ,  -  .      
 . (  extern    8.2.)
             , 
     .     
 ,     ,   .   
           
  . (        
8.2.)

                                  3.2.2.  

    ,  ,     ,  
 .       .  ++
   ,    
  gosh_this_is_an_impossibly_name_to_type .
        ++       
;   3.1    .

 3.1.   C++

   asm          auto      bool     break            case
   catch        char      class    const            const_cast
   continue     default   delete   do               double
   dynamic_cast else      enum     explicit         export
   extern       false     float    for              friend
   goto         if        inline   int              long
   mutable      namespace new      operator         private
   protected    public    register reinterpret_cast return
   short        signed    sizeof   static           static_cast
   struct       switch    template this             throw
   true         try       typedef  typeid           typename
   union        unsigned  using    virtual          void
   volatile     wchar_t   while

         ,   
    :

         ,  index (
     : Index    ,  INDEX  ,   
       #define);

                                                                ++   92

      - ,    
    , : birth_date  salary;

      , , , birth_date,   
    (birth_date),    
    (birthDate). ,  ,  
    
,     _____   .
       .

                               3.2.3.  

              
      . :

   double salary;
   double wage;
   int month;
   int day;
   int year;
   unsigned long distance;

           .    
   :

   double salary, wage;
   int month,
      day, year;
   unsigned long distance;

          .  
  ,  ++ ,   
  .      
 (   new),     ,  
     .
         ,   
  .      , 
    ,  ,     
.       ,  
    . (       2.3. 
       ,   3.11  3.15,
     string  complex   .)

   int main() {
      //   
      int ival;
      
      //   string 
      //   
      string project;

                                                                  ++   93

      // ...
   }

            . 
++       ,  
 :

   int ival = 1024;
   string project = "Fantasia 2000";

 ,      :

   int ival( 1024 );
   string project( "Fantasia 2000" );

             ival
 1024    project  "Fantasia 2000".
        :

   double salary = 9999.99, wage = salary + 0.01;
   int month = 08;
   day = 07, year = 1955;

      (   )    ,
     wage   
  salary   .  , :

   // ,  
   int bizarre = bizarre;

  ,   .
            :

   // ival   0,  dval - 0.0
   int ival = int();
   double dval = double();

     :

   // int()     10 
   vector< int > ivec( 10 );
                                                               ++   94

          int().
(     vector   2.8.     .  
3.10   6.)
         , 
 . :

   #include <cmath>
   #include <string>

   double price = 109.99, discount = 0.16;
   double sale_price( price * discount );
   string pet( "wrinkles" );

   extern int get_value();
   int val = get_value();

   unsigned abs_val = abs( val );

abs()   ,    .
get_value()    ,   .

                                  3.3

           ?

   (a) int car = 1024, auto = 2048;
   (b) int ival = ival;
   (c) int ival( int() );
   (d) double salary = wage = 9999.99;
   (e) cin >> int input_value;

                                    3.4

      l-  r-.  .

                                    3.5

        name  student    
  :

   (a) extern string name;
      string name( "exercise 3.5a" );

   (b) extern vector<string> students;
       vector<string> students;

                                       3.6

        ++?   ,   
 :

                                                                  ++   95

(a) int car = 1024, auto = 2048; (b) int ival = ival;
(c) int ival( int() );           (d) double salary = wage = 9999.99;
(e) char 1_or_2 = '1';           (f) float Float = 3.14f;


                                     3.7

           
?


   string global_class;
   int global_int;

   int main() {
      int local_int;
      string local_class;
      // ...
   }

                                     3.3. 

             2.2.
   ,       
  .      
  ,     , ,
     ,      
         .
         ,   
     :   ,  
 ,      5.    , 
   .      
    ,   ,    ,
  :

     int,    1000,   
     1000-1003 ( 32- );
     double,    1000,   
     1000-1007 ( 32- ).

    :

   int *ip1, *ip2;
   complex<double> *cp;
   string *pstring;
   vector<int> *pvec;


5           :   
   (.  7.9).

                                                             ++   96

   double *dp;

       .    
      (. : ip1  ip2).  
 lp      long,  lp2    long:

   long *lp, lp2;

      fp     float,  fp2   
:

   float fp, *fp2;

     (*)       
     .   
    :

   string *ps;
   string* ps;

        :   
 ,          :

   //: ps2    !
   string* ps, ps2;

    ,   ps,  ps2  ,    
  .
       0, ,      .
    int:

   int ival = 1024;

        int pi  pi2:

   //pi   
   int *pi = 0;

   // pi2   ival
   int *pi2 = &ival;

   // : pi  pi2   ival
   pi = pi2;

   // pi2   
   pi2 = 0;

        ,   :

                                                              ++   97

   // : pi     int
   pi = ival

           ,  
  .    :

   double dval;
   double *ps = &dval;

   ,  ,   :

   //  
   //    : int* <== double*
   pi = pd
   pi = &dval;

      ,   pi      dval  
        .    
 ,       
   .
   ,  ,      ,   , 
   (,       - ). 
      void,  
    ,     :

   // : void*  
   //   
   void *pv = pi;
   pv = pd;

    ,    void*, ,     
 . ,       ,    
     -  . (  
    void  4.14.)
        ,   ,   
,   ,   (*). 
  :

   int ival = 1024, ival2 = 2048;
   int *pi = &ival;

      ival,    
 pi:

                                                             ++   98


   //    ival  ival2
   *pi = ival2;

   //    ival  rvalue  lvalue
   *pi = abs(*pi); // ival = abs(ival);

   *pi = *pi + 1; // ival = ival + 1;

         (&)    int,  
  int*

   int *pi = &ival;

           int* (  int),  
    int, .. int**. int**    ,  
   int.  ppi,     int*,
  ival.     ival,   
ppi   .

   int **ppi = &pi;
   int *pi2 = *ppi;

   cout << " ival\n"
        << " : " << ival << "\n"
        << " : " << *pi << "\n"
        << "  : " << **ppi << "\n"
        << endl;

         .  
  ,       :

   int i, j, k;
   int *pi = &i;

   // i = i + 2
   *pi = *pi + 2;

   //  ,   pi,  2
   pi = pi + 2;

        ,     .
   1        
,    .   char  1 ,
int 4  double 8,   2    char, int  double  
   2, 8  16.    ?  
       ,     1
  ,       .  
        ;  
     .
            
    :

   int ia[10];

                                                             ++   99

   int *iter = &ia[0];
   int *iter_end = &ia[10];
   while (iter != iter_end) {
      do_something_with_value (*iter);
      ++iter;
   }

                                          3.8

     :

   int ival = 1024, ival2 = 2048;
   int *pi1 = &ival, *pi2 = &ival2, **pi3 = 0;

         ? 
    ?

   (a) ival = *pi3; (e) pi1 = *pi3;
   (b) *pi2 = *pi3; (f) ival = *pi1;
   (c) ival = pi2;  (g) pi1 = ival;
   (d) pi2 = *pi1;  (h) pi3 = &pi2;

                                           3.9

             ++,    
 . , 

   pi = &ival;
   pi = pi + 1024;

    ,  pi      .
             ?

                                         3.10

   ,    
:

   int foobar(int *pi) {
      *pi = 1024;
       return *pi;
   }

   int main() {
      int *pi2 = 0;
      int ival = foobar(pi2);
      return 0;
   }

      ?    ?

                                                             ++   100

                                  3.11

            
 -   ++     
  .   ,      ?
        ,   
   ?

                                 3.4.  

    ++       ,   ,  
string    ++.  string   
     ,     ,
       ,  
. (        ,
   main().      7.)

                           3.4.1.   

      ,      ++    .
      ,      
   char*.      
  . :

   //   
   int strlen( const char* );

   //   
   int strcmp( const char*, const char* );

   //     
   char* strcpy( char*, const char* );

         ++.    
   :

   #include <cstring>

     char,       ,  
   .      ,


   const char *st = "  \n";

          st  
 .     ,   ?
       . 
    ,     1, 
    . :

                                                               ++   101

   while (*st++ ) { ... }

st ,      . 
     , , ,  ,
      0.   ++  1 
 st        .
        ,   . ,
,       (    ),
     :

   int string_length( const char *st )
   {
      int cnt = 0;
      if ( st )
        while ( *st++ )
          ++cnt;
      return cnt;
   }

        :   
    (      )   
,      (   ,   
  ).

   // pc1     
   char *pc1 = 0;

   // pc2   
   const char *pc2 = "";

          
 -        
 .      ,
 .  :   .   .
 .

   #include <iostream>

   const char *st = "  \n";

   int main() {
      int len = 0;
      while ( st++ ) ++len;

      cout << len << ": " << st;
      return 0;
   }

        st  . ,   0
  ,    st,   .  
     ( ),      
,     .

                                                               ++   102

         .  
,    .       ?

   #include <iostream>

   const char *st = "  \n";

   int main()
   {
      int len = 0;
      while ( *st++ ) ++len;

      cout << len << ": " << st << endl;
      return 0;
   }

      ,      st   
 ,  ,       
.       ,    
  .
       :

   st = st - len;
   cout << len << ": " << st;

       - ,    .   :

   18:   

     ,         
. st        1. , , 
:

   st = st  len - 1;

     :

   18:   

     ,     . 

st = st  len - 1;

  ,   ,    
 ,     st.  
    ,     .  
     ,     
.       .  

                                                               ++   103

        ,
  st:

   const char *p = st;

    p      ,   st
:

   while ( *p++ )

                                     3.4.2.  string

       ,       
   - ,       . 
       
        ,  
      .   , 
         !   
   .    string
  ++      
.
       ,   
 string:

      (  )  
      string.      ;
       .    
      strcpy();
           .  
             ;
       .    
     strcmp();
     ,      , 
       .      strcat(),
          ,  
      strcpy()  strcat();
     .       
      strlen();
    ,   .      
       :

   char str = 0;
   //...
   if ( ! str || ! *str )
      return;

                                                               ++   104

    string   ++     (
 ,      6).      
   .
         string,  
  :

   #include <string>

        ,    string 
  :

   #include <string>
   string st( "  \n" );

      - size() (   
 ).

   cout << " "
        << st
        << ": " << st.size()
        << " ,    \n";

         :

   string st2; //  

     ,   ? ,      0:

   if ( ! st.size() )
      // : 

        empty(),  true    
false  :

   if ( st.empty() )
   // : 

         string   
 :

   string st3( st );

    st3   st.    ,   
?    (==):

   if ( st == st3 )
      //  


                                                                ++   105

        ?     :

   st2 = st3; //  st3  st2

         (+)    
 (+=).    :

   string s1( "hello, " );
   string s2( "world\n" );

       ,     , 
:

   string s3 = s1 + s2;

        s2  s1,   :

      s1 += s2;

         string   
,      .   , 
, ,        
,       string:

   string s1( "hello" );

   const char *pc = ", ";
   string s2( "world" );

   string s3 = s1 + pc + s2 + "\n";

      ,   ,  
       string.  
     string:

   string s1;
   const char *pc = "a character array";

   s1 = pc; // 

    , ,  .   
      :

   char *str = s1; //  

      ,    - 
   c_str():

   char *str = s1.c_str(); //  
                                                             ++   106

    c_str()     ,  
 string   ,         .
        char *str    
. c_str()     ,  
       ,
 

   const char *

(        const).  
  :

   const char *str = s1.c_str(); // 

        string,    ,  
    . , ,  ,  
  :

   string str( "fa.disney.com" );

   int size = str.size();
   for ( int ix = 0; ix < size; ++ix )
      if ( str[ ix ] == '.' )
         str[ ix ] = '_';

     ,       string  .   ,  
      . , 
    -  replace():

   replace( str.begin(), str.end(), '.', '_' );

replace()     ,      
2.8        12.     
begin()  end(),        ,  
,    ,  .

                                          3.12

        :

   (a) char ch = "The long and winding road";
   (b) int ival = &ch;
   (c) char *pc = &ival;
   (d) string st( &ch );
   (e) pc = 0; (i) pc = '0';
   (f) st = pc; (j) st = &ival;
   (g) ch = pc[0]; (k) ch = *pc;
   (h) pc = st; (l) *pc = ival;

                                           3.13

         :

                                                           ++   107

   while ( st++ )
      ++cnt;

   while ( *st++ )
      ++cnt;

                                       3.14

       .   
 ,    string:

   // *****    C- *****
   #include <iostream>
   #include <cstring>

   int main()
  {
     int errors = 0;
     const char *pc = "a very long literal string";
     for ( int ix = 0; ix < 1000000; ++ix )
     {
        int len = strlen( pc );
        char *pc2 = new char[ len + 1 ];
        strcpy( pc2, pc );
        if ( strcmp( pc2, pc ))
           ++errors;
        delete [] pc2;
     }

     cout << "C-: "
          << errors << " .\n";
   }


   // *****     string *****
   #include <iostream>
   #include <string>

   int main()
   {
       int errors = 0;
       string str( "a very long literal string" );
       for ( int ix = 0; ix < 1000000; ++ix )
       {
          int len = str.size();
           string str2 = str;

          if ( str != str2 )
      }

      cout << " string: "
           << errors << " .\n;

                                                      ++   108

   }

      ?

   ,        .   
 ?    ?

                                         3.15

      -        string,
   ?   .

                                  3.5.  const

     :

   for ( int index = 0; index < 512; ++index )
      ... ;

      512   .    
  .       
  512?     ?   ...
          . ,
   10 000 ,   512   4%  . , 
80%   512     1024.    
     ,   ,   
?
       :      512.
   ,  bufSize,    
 : ,      .

   index < bufSize

        bufSize    400   
 320  .      
  !   512 .

   int bufSize = 512; //   
   // ...

   for ( int index = 0; index < bufSize; ++index )
      // ...

      :  bufSize   l-,
     ,     
.         
(=)   (==):

   //    bufSize


                                                            ++   109

   if ( bufSize = 1 )
      // ...

         bufSize   1,  
     .   
   ,     .
     const   .   

   const int bufSize = 512; //   

       512,    
 :    :  
   ,    ,  
.

   // :    
   if ( bufSize = 0 ) ...

       ,      
 .       
 :

   const double pi; // :  

     .     
.      ?    
  ?

   const double minWage = 9.60;

   // ? ?
   double *ptr = &minWage;

        ?  minWage 
,    .   ,    
:

   *ptr += 1.40; //   minWage!

    ,          
        .  
     .   
     .
    ,       ? .  
 ,    const:

   const double *cptr;
                                                                 ++   110

 cptr      const double.    ,  
   ,  ,     . :

   const double *pc = 0;
   const double minWage = 9.60;

   // :    minWage   pc
   pc = &minWage;

   double dval = 3.14;

   // :    minWage   pc
   //  dval   
   pc = &dval; // 

   dval = 3.14159; //

   *pc = 3.14159; // 

          .   ,
        :

   pc = &dval;

            
 .  dval       , 
    dval  pc. (- ,    
 ,        
  .)
            
  .    ,  ,
      ,    
. :

   //        
   //     
   int strcmp( const char *str1, const char *str2 );

(         7,    
.)
      . (    
     !).   
  ,   . :

   int errNumb = 0;
   int *const currErr = &errNumb;

    curErr      .  ,   
     ,     .
       curErr:

                                                             ++   111

   do_something();

      errorHandler();
      *curErr = 0; // :   errNumb

??   if ( *curErr ) {
??   }

          :

   curErr = &myErNumb; // 

          
.

   const double pi = 3.14159;
   const double *const pi_ptr = &pi;

    ,    pi_ptr,     
    .

                                        3.16

       .     ?

   (a) int i;          (d) int *const cpi;
   (b) const int ic;   (e) const int *const cpic;
   (c) const int *pic;

                                     3.17

       ? ?

   (a) int i = -1;
   (b) const int ic = i;
   (c) const int *pic = &ic;
   (d) int *const cpi = &ic;
   (e) const int *const cpic = &ic;

                                   3.18

       ,   
. .

   (a) i = ic;     (d) pic = cpic;
   (b) pic = &ic;  (i) cpic = &ic;
   (c) cpi = pic;  (f) ic = *cpic;


                                                           ++   112

                               3.6.  

    ,   ,    
 .     , 
 ,      .     
  ,   .  
    .     
    .
       (&)  
.    . :

   int ival = 1024;

   // : refVal -   ival
   int &refVal = ival;

   // :    
   int &refVal2;

   ,   ,     ,   
   ,   .     
:

   int ival = 1024;

   // : refVal   int,   int*
   int &refVal = &ival;

   int *pi = &ival;

   // : ptrVal -   
   int *&ptrVal2 = pi;

    ,       ,    
 (        
).         refVal,
    ival  ,   refVal.

   int min_val = 0;

   // ival   min_val,
   //   refVal    min_val
   refVal = min_val;

            .  
    . :

   refVal += 2;

                                                               ++   113

 2  ival  ,    refVal. 

  int ii = refVal;

 ii   ival,

   int *pi = &refVal;

 pi  ival.
           ,   
     (&)     (  ,  
 ). :

   //     int
   int ival = 1024, ival2 = 2048;

   //      
   int &rval = ival, rval2 = ival2;

   //   ,     
   int inal3 = 1024, *pi = ival3, &ri = ival3;

   //   
   int &rval3 = ival3, &rval4 = ival2;

           (,
,       ),  
   ,   . :

   double dval = 3.14159;

   //     
   const int &ir = 1024;
   const int &ir2 = dval;
   const double &dr = dval + 1.0;

         const,      
 . , ,      
, .  .
         :       
  ,    .   
 ,       
. ,   :

   double dval = 1024;
   const int &ri = dval;

     :

                                                            ++   114
   int temp = dval;
   const int &ri = temp;

           ri,     
dval,  temp.  dval    ,    
.     ,  
         
const.
       ,      .  
     ,     
 :

   const int ival = 1024;
   // :   
   int *&pi_ref = &ival;

        const   :

   const int ival = 1024;
   //   
   const int *&pi_ref = &ival;

     ?   ,  ,  pi_ref 
       int.    
   ,     :

   const int ival = 1024;
   // 
   int *const &piref = &ival;

          . -, 
       . -,
     ,   ,    .
  .   :

   int *pi = 0;

   pi  ,   ,  pi  
   .     

   const int &ri = 0;

  :

                                                                ++   115

   int temp = 0;
   const int &ri = temp;

      ,    :

   int ival = 1024, ival2 = 2048;
   int *pi = &ival, *pi2 = &ival2;
  pi = pi2;

 ival,    pi,  ,  pi 
   ival2.  pi,  pi2        
 ival2.
        :

   int &ri = ival, &ri2 = ival2;
   ri = ri2;

   ival ,   ri -  ival.
     ++       ,
       . :

   //   

   //     next_value
   bool get_next_value( int &next_value );

   //  
   Matrix operator+( const Matrix&, const Matrix& );

      -  -?   :

   while (get_next_value( ival )) ...

      :

   int &next_value = ival;

(       
   7.)

                                           3.19

                                                                  ++   116

        ? .     ?

   (a) int ival = 1.01; (b) int &rval1 = 1.01;
   (c) int &rval2 = ival; (d) int &rval3 = &ival;
   (e) int *pi = &ival; (f) int &rval4 = pi;
   (g) int &rval5 = pi*; (h) int &*prval1 = pi;
   (i) const int &ival2 = 1; (j) const int &*prval2 = &ival;

                                   3.20

          (
   )?

   (a) rval1 = 3.14159;
   (b) prval1 = prval2;
   (c) prval2 = rval1;
   (d) *prval2 = ival2;

                                     3.21

       :

   (a) int ival = 0;
       const int *pi = 0;
       const int &ri = 0;

   (b) pi = &ival;
      ri = &ival;
   pi = &rval;


                                      3.7.  bool

     bool      : true  false. :

   //  
   string search_word = get_word();

   //   found
   bool found = false;

   string next_word;
   while ( cin >> next_word )
      if ( next_word == search_word )
         found = true;
   // ...

   //  : if ( found == true )
   if ( found )
      cout << "ok,   \n";
   else cout << ",    .\n";

    bool      ,       signed,
unsigned, short  long,    :

                                                              ++   117
   // 
   short bool found = false;

     bool     int.  true   1, 
false   0. :

   bool found = false;
   int occurrence_count = 0;

   while ( /* mumble */ )
   {
      found = look_for( /* something */ );

      //  found   0  1
      occurrence_count += found;

   }

              
  bool.   0   false,     true:

   //   
   extern int find( const string& );
   bool found = false;
   if ( found = find( "rosebud" ))
      // : found == true

   //    
   extern int* find( int value );

   if ( found = find( 1024 ))
   // : found == true

                                     3.8. 

      ,     
. ,       :  ,  , 
.
   ,        :

   const int input = 1;
   const int output = 2;
   const int append = 3;

   :

                                                              ++   118

   bool open_file( string file_name, int open_mode);
   // ...
   open_file( "Phoenix_and_the_Crane", append );

     ,    ,    
,  ,    open_file()   1, 2
 3.
        .   :

   enum open_modes{ input = 1, output, append };

    open_modes.      
  1, 2  3,      
 .          
  ,      :

   void open_file( string file_name, open_modes om );

input, output  append   .  
        .
  open_modes (  )    
,        . :

   open_file( "Phoenix and the Crane", append );

     ,     
 (     ),   .
     ,    
,     :

   // : 1     open_modes
   open_file( "Jonah", 1 );

        open_modes,     
      :

   open_modes om = input;
   // ...
   om = append;
   open_file( "TailTell", om );

        .    
:

   cout << input << " " << om << endl;

   :

                                                              ++   119

1 3

     ,    ,    
,    ,    . 
 ,   :

   cout << open_modes_table[ input ] << " "
      << open_modes_table[ om ] << endl

    :

   input append

    ,     :

   //  
   for ( open_modes iter = input; iter != append; ++inter )
   // ...

         enum,    
  ,  .       0,  
1   .        . 
          1 , 
,     .        1 
input,   output  append   2  3.    :

   // shape == 0, sphere == 1, cylinder == 2, polygon == 3
   enum Forms{ share, spere, cylinder, polygon };

    ,     ,  
. :

   // point2d == 2, point2w == 3, point3d == 3, point3w == 4
   enum Points { point2d=2, point2w, point3d=3, point3w=4 };

   ,    ,  ,    
    .    
    ,     
          . 
        
 :

                                                            ++   120

   void mumble() {
      Points pt3d = point3d; // : pt2d == 3

      // : pt3w   int
      Points pt3w = 3;

      // : polygon     Points
      pt3w = polygon;

      // :    Points
      pt3w = pt3d;
   }

          
   int. :

   const int array_size = 1024;

   // : pt2w  int
   int chunk_size = array_size * pt2w;


                                    3.9.  

         2.1.       ,
           .
:

   int ival;

 ival    int,  

   int ia[ 10 ];

      int.     ,  
,       :

   ival = ia[ 2 ];

  ival    ia   2. 

   ia[ 7 ] = ival;

    7  ival.
        ,    . 
    (  1)     .
       ,  ,   
 ,     .  
    :

                                                              ++   121

   extern int get_size();

   // buf_size  max_files 
   const int buf_size = 512, max_files = 20;
   int staff_size = 27;

   // : 
   char input_buffer[ buf_size ];

   // :  : 20 - 3
   char *fileTable[ max_files-3 ];

   // :  
   double salaries[ staff_size ];

   // :   
   int test_scores[ get_size() ];

    buf_size  max_files  ,   
input_buffer  fileTable .   staff_size   ( 
  27), , salaries[staff_size] .
(       staff_size  
  salaries.)
 max_files-3      , ,
  fileTable[max_files-3]  .
    0,     10  
    1  10,  0  9.     
:

   int main()
   {
      const int array_size = 10;
      int ia[ array_size ];

      for ( int ix = 0; ix < array_size; ++ ix )
         ia[ ix ] = ix;
   }

        ,   
   ,  :

   const int array_size = 3;
   int ia[ array_size ] = { 0, 1, 2 };

        ,      :
    :

   //   3
   int ia[] = { 0, 1, 2 };
                                                              ++   122

       ,   ,   . 
      .    ,
  ,     .  
   ,     :

   // ia ==> { 0, 1, 2, 0, 0 }
   const int array_size = 5;
   int ia[ array_size ] = { 0, 1, 2 };

           
   ,    .   
   . ,

   const char cal[] = {'C', '+', '+' };
   const char cal2[] = "C++";

     ca1  3,  ca2  4 (   
  ).     :

   // :  "Daniel"   7 
   const char ch3[ 6 ] = "Daniel";

       ,  
   .  ,    
.       :

   const int array_size = 3;
   int ix, jx, kx;

   // :    int*
   int *iar [] = { &ix, &jx, &kx };

   // error:   
   int &iar[] = { ix, jx, kx };

   int main()
   {
      int ia3{ array_size ]; // 

      // :    
      ia3 = ia;
      return 0;
   }

        ,      
 :

                                                                ++   123

   const int array_size = 7;
   int ia1[] = { 0, 1, 2, 3, 4, 5, 6 };

   int main()
   {
      int ia3[ array_size ];

      for ( int ix = 0; ix < array_size; ++ix )
      ia2[ ix ] = ia1[ ix ];

      return 0;
   }

          ,   
. :

   int someVal, get_index();
   ia2[ get_index() ] = someVal;

   ,   ++         
,    .      , 
     .      
.  ,       , 
   ,       ,  
   .

                                3.22

         ? .

   (a) int ia[ buf_size ]; (d) int ia[ 2 * 7 - 14 ]
   (b) int ia[ get_size() ]; (e) char st[ 11 ] = "fundamental";
   (c) int ia[ 4 * 7 - 14 ];

                                  3.23

          
 .   :

   int main() {
      const int array_size = 10;
      int ia[ array_size ];

      for ( int ix = 1; ix <= array_size; ++ix )
         ia[ ia ] = ix;
      // ...
   }

                                                             ++   124

                             3.9.1.  

    ++     ,   
        
.    :

   int ia[ 4 ][ 3 ];

     (4)   ,  (3)   . 
ia           . 
    :

   int ia[ 4 ][ 3 ] = {
      { 0, 1, 2 },
      { 3, 4, 5 },
      { 6, 7, 8 },
      { 9, 10, 11 }
   };

     ,     ,  
,  ,    .   
    ,   :

   int ia[4][3] = { 0,1,2,3,4,5,6,7,8,9,10,11 };

          .
    :

   int ia[ 4 ][ 3 ] = { {0}, {3}, {6}, {9} };

        ,    .
           , 
    0.

   int ia[ 4 ][ 3 ] = { 0, 3, 6, 9 };

           
   (    ).  
      :

   int main()
   {
      const int rowSize = 4;
      const int colSize = 3;
      int ia[ rowSize ][ colSize ];

      for ( int = 0; i < rowSize; ++i )
            for ( int j = 0; j < colSize; ++j )
                 ia[ i ][ j ] = i + j j;
   }
                                                               ++   125

   

   ia[ 1, 2 ]

      ++,     , 
  .       1  2.
         , 
    2 (.     4.2). 
 ia[1,2]  ia[2].      .

                      3.9.2.    

       :

   int ia[] = { 0, 1, 1, 2, 3, 5, 8, 13, 21 };

        ?

           
 :

    ia;
    &ia[0]

            :

   //     
   *ia;
   ia[0];

        ,   :

   &ia[1];

       , 

   ia+1;

     . ,    
  :

   *(ia+1);
    ia[1];
                                                           ++   126

      :

   *ia+1



   *(ia+1);

        ,    (
     4.13).    
  ia     ,   
  1.       .
          ,     
 ,    . :

   #include <iostream>

   int main()
   {
      int ia[9] = { 0, 1, 1, 2, 3, 5, 8, 13, 21 };
      int *pbegin = ia;

      while ( pbegin != pend ) {
         cout << *pbegin <<;
         ++pbegin;

   int *pend = ia + 9;
}

    pbegin     .  
      1,      
.  ,  ?      
 pend    ,    
 ia.    pbegin   pend,  ,  
.
      ,       
   ,      :

   #inc1ude <iostream>

   void ia_print( int *pbegin, int *pend )
   {
      while ( pbegin != pend ) {
          cout << *pbegin << ' ';
          ++pbegin;
      }
   }

   int main()
   {
        int ia[9] = { 0, 1, 1, 2, 3, 5, 8, 13, 21 };
        ia_print( ia, ia + 9 );
   }
                                                            ++   127

       , ,     
  int.      :  
   (      2.5):

   #inc1ude <iostream>

   template <c1ass e1emType>
   void print( elemType *pbegin, elemType *pend )
   {
      while ( pbegin != pend ) {
         cout << *pbegin << ' ';
         ++pbegin;
      }
   }

         print()     :

   int main()
   {
      int ia[9] = { 0, 1, 1, 2, 3, 5, 8, 13, 21 };
      double da[4] = { 3.14, 6.28, 12.56, 25.12 };
      string sa[3] = { "piglet", "eeyore", "pooh" };

      print( ia, ia+9 );
      print( da, da+4 );
      print( sa, sa+3 );
   }

      .    
  (       3.4), 
 .         
,      . , ,  
   :

   #include <a1gorithm>

   int main()
   {
      int ia[6] = { 107, 28, 3, 47, 104, 76 };
      string sa[3] = { "piglet", "eeyore", "pooh" };

      sort( ia, ia+6 );
      sort( sa, sa+3 );
   };

   (        12;   
   .)
      ++   ,  
   . (     2.8.) 
       vector,
 -  .

                                                              ++   128


                                  3.10.  vector

     vector (.  2.8)   
 .      , 
  .   ,   
   .       
   ,        7.8. 
vector,    string,     ++.
         :

   #include <vector>

          ,  
    STL.      vector 
  ,    .    :

   vector< int > ivec( 10 );

     :

   int ia[ 10 ];

            :

   void simp1e_examp1e()
   {
      const int e1em_size = 10;

      vector< int > ivec( e1em_size );
      int ia[ e1em_size ];

      for ( int ix = 0; ix < e1em_size; ++ix )
        ia[ ix ] = ivec[ ix ];
      // ...
   }

       ,   size(),  ,  
,    empty(). :

   void print_vector( vector<int> ivec )
   {
      if ( ivec.empty() )
         return;

      for ( int ix=0; ix< ivec.size(); ++ix )
         cout << ivec[ ix ] << ' ';
   }

        .    
    0.      

                                                             ++   129

,         (.  2.3).
     ,  :

   vector< int > ivec( 10, -1 );

      -1.
         :

   int ia[ 6 ] = { -2, -1, , 1, 2, 1024 };

      vector   .   
       :

   vector< int > ivec( ia, ia+6 );

     ivec         ia 
 ,   .      
   ,    :

   //  3 : ia[2], ia[3], ia[4]
   vector< int > ivec( &ia[ 2 ], &ia[ 5 ] );

            
    vector    
   . :

   vector< string > svec;

   void init_and_assign()
   {
      //    
      vector< string > user_names( svec );
     // ...

     //     
     svec = user_names;
   }

      STL6,       
.       ,    :

vector< string > text;

6 STL   Standard Template Library.  
  ++  vector, string  ,  
        STL.

                                                          ++   130

           . , 
push_back()    .   , 
         :

   string word;
   while ( cin >> word ) {
      text.push_back( word );
   // ...
   }

             :

   cout << endl;

        :

   cout << " : \n";

   for ( vector<string>::iterator it = text.begin();it != text.end(); ++it )
      cout << *it << ' ';
   cout << endl;

        ,    
 .
   

   *it;

      . 

   ++it;

    .      . 
  STL    :

   vector<int> ivec;

  :

   ivec[0] = 1024;

           ivec;    
  size().

                                                              ++   131

       .     
, :

   vector<int> ia( 10 );

     ,    
.     ,   ,  
   :

   const int size = 7;
   int ia[ size ] = { 0, 1, 1, 2, 3, 5, 8 };
   vector< int > ivec( size );
   for ( int ix = 0; ix < size; ++ix )
      ivec.push_back( ia[ ix ] );

        ivec   ia,  
  ivec  14.
     STL,    ,     . ( 
        6.)

                                      3.24

        ?

   int ia[ 7 ] = { 0, 1, 1, 2, 3, 5, 8 };

   (a) vector< vector< int > > ivec;
   (b) vector< int > ivec = { 0, 1, 1, 2, 3, 5, 8 };
   (c) vector< int > ivec( ia, ia+7 );
   (d) vector< string > svec = ivec;
   (e) vector< string > svec( 10, string( "null" ));

                                      3.25

     :

   bool is_equa1( const int*ia, int ia_size, const vector<int> &ivec );

    is_equal()    .    
       . , ,  
  ,   true,    
  false.     .  
main(),   is_equal().

                                3.11.  complex

      complex       . 
,       :

                                                              ++   132

   #include <comp1ex>

            .  
      .  
   

   2 + 3i

 2   ,  3i  .     
complex:

  //   : 0 + 7-i
   comp1ex< double > purei( 0, 7 );

   //    0: 3 + Oi
   comp1ex< float > rea1_num( 3 );

   //  ,     0: 0 + 0-i
   comp1ex< long double > zero;

   //     
  comp1ex< double > purei2( purei );

    complex,   vector,  ,    
 float, double  long double,    .  
    complex:

   complex< double > conjugate[ 2 ] = {
      complex< double >( 2, 3 ),
      complex< double >( 2, -3 )
   };

           :

   complex< double > *ptr = &conjugate[0];
   complex< double > &ref = *ptr;

      , , , , ,
     . (     
 complex  4.6.)

                            3.12.  typedef

    typedef       
 . :

                                                                ++   133

   typedef double wages;
   typedef vector<int> vec_int;
   typedef vec_int test_scores;
   typedef bool in_attendance;
   typedef int *Pint;

   ,     typedef,     ,
  :

   // double hourly, weekly;
   wages hourly, weekly;

   // vector<int> vecl( 10 );
   vec_int vecl( 10 );

   // vector<int> test0( c1ass_size );
   const int c1ass_size = 34;
   test_scores test0( c1ass_size );

   // vector< bool > attendance;
   vector< in_attendance > attendance( c1ass_size );

   // int *table[ 10 ];
   Pint table [ 10 ];

         typedef,    
,   ,     
.
   ,     typedef? 
    ,      
.  ,       
,       (.    3.14), 
     -  (.  13.6).
   ,       . 
   typedef    .
 :

   typedef char *cstring;

      cstr   :

   extern const cstring cstr;

   ,   :

   const char *cstr

     .  const   cstr,    
   char:

   char *const cstr;

                                                              ++   134

                            3.13.  volatile

      volatile (,  ),  
      ,  ,
   .    , 
         .
 volatile    const:

   volatile int disp1ay_register;
   volatile Task *curr_task;
   volatile int ixa[ max_size ];
   volatile Screen bitmap_buf;

display_register     int. curr_task   
   Task. ixa    ,  
    . bitmap_buf   
 Screen,       .
       volatile   ,
    ,        .
      ,  
.

                                 3.14.  pair

    pair ()   ++    
  ,     -  . 
      .    
   :

   #inc1ude <uti1ity>

   , 

   pair< string, string > author( "James", "Joyce" );

  author  pair,     .
         first  second:

   string firstBook;

   if ( Joyce.first == "James" &&  Joyce.second == "Joyce" )
   firstBook = "Stephen Hero";

          , 
  typedef:

                                                             ++   135

   typedef pair< string, string > Authors;
   Authors proust( "marcel", "proust" );
   Authors joyce( "James", "Joyce" );
   Authors musil( "robert", "musi1" );

       .     
,         .

   class EntrySlot;
   extern EntrySlot* 1ook_up( string );

   typedef pair< string, EntrySlot* > SymbolEntry;

   SymbolEntry current_entry( "author", 1ook_up( "author" ));
   // ...

   if ( EntrySlot *it = 1ook_up( "editor" ))
   {
      current_entry.first = "editor";
      current_entry.second = it;
   }

   (     pair        6 
     12.)

                               3.15.  

         ;    
 string, vector, complex  pair,  .   2  
   ,    -
,     Array.  ,   
,    String,    , 
,          2.3. ( 
   13, 14  15.       , 
   . ,    ++,
          
 .)
     String      String,
     ,    
    .       
  .     String 
     .  ,  :
 size()      ;  
  String   String    ;   
/  .       
        .
        class,   
   ,  .       ,
  public ()  private ().  , 

                                                           ++   136

,   ,     
 - .  -   
,  ,  ,     
 .      -, 
 .        _string 
  char,   _size  int. _size     
,  _string     .   
 :

   #inc1ude <iostream>

   class String;
   istream& operator>>( istream&, String& );
   ostream& operator<<( ostream&, const String& );

   class String {
   public:
      //  
      //   
      // String strl; // String()
      // String str2( "literal" ); // String( const char* );
      // String str3( str2 ); // String( const String& );

      String();
      String( const char* );
      String( const String& );

      // 
      ~String();

      //  
      // strl = str2
      // str3 = "a string literal"

      String& operator=( const String& );
      String& operator=( const char* );

      //    
      // strl == str2;
      // str3 == "a string literal";

      bool operator==( const String& );
      bool operator==( const char* );

      //     
      // strl[ 0 ] = str2[ 0 ];

      char& operator[]( int );

      //    
      int size() { return _size; }
      char* c_str() { return _string; }

   private:
      int _size;
      char *_string;
   };

                                                              ++   137

    String   .      2.3, 
        , 
    /   .  

   String();

   ,      
 .   :

   String str1;

 str1   .
         . , 

   String str2(" ");

 

   String(const char*);

 

   String str3(str2);



   String(const String&);

         . 
 , String(const String&),  ,   
    .
     :

   String str4(1024);

    ,        
 int.
        :

   return_type operator op (parameter_list);

 operator   ,  op     : +, =, ==, []
  . (   .   15.)  
   :

   char& operator[] (int);

         int     char.
     ,   

                                                              ++   138

  .    String    
      .
     -        (.) 
 (->).       String:

   String object("Danny");
   String *ptr = new String ("Anna");
   String array[2];

        size()   :

   vector<int> sizes( 3 );

   //     objects (.);
   // objects   5
   sizes[ 0 ] = object.size();

   //     pointers (->)
   // ptr   4
   sizes[ 1 ] = ptr->size();

   //    (.)
   // array[0]   0
   sizes[ 2 ] = array[0].size();

      5, 4  0.
         ,  :

   namel = name2;

    -     , 
       ,    . (
 size()  c_str()   .)   
 ,    ,   ,    
.         ,
, String.C,         (String.h 
 ),     :

                                                             ++   139

   //   : String.

   //    String
   #inc1ude "String.h"

   //    strcmp()
   #inc1ude <cstring>
   bool //   
   String:: // ,   
      operator== //  :  
   (const String &rhs) //  
   {
      if ( _size != rhs._size )
        return false;
   return strcmp( _strinq, rhs._string ) ?
      false : true;
   }

   ,  strcmp()     .   
  ,  0        
 .   (?:)  ,   
.   ,   ,   
,      .     
 false,  strcmp()   ,  true   .
(     4.7.)
       ,    
,       (inline). 
     ,      
. (     7.6.) -,
  ,    .    
 ,    ,     inline:

   inline bool
   String::operator==(const String &rhs)
   {
       //   
   }

          ,
  .   ==  , 
       String.C  String.h.
         String  
 :

   inline bool
   String::operator==(const char *s)
   {
      return strcmp( _string, s ) ? false : true;
   }

                                                               ++   140

        . ,     ,
         ,    .
   .     ,   
 .

   #include <cstring>

   // default constructor
   inline String::String()
   {
      _size = 0;
      _string = 0;
   }

   inline String::String( const char *str )
   {
      if ( ! str ) {
         _size = 0; _string = 0;
      }
      else {
         _size = str1en( str );
         _string = new char[ _size + 1 ];
        strcpy( _string, str );
   }

      // copy constructor
      inline String::String( const String &rhs )
      {
         size = rhs._size;
         if ( ! rhs._string )
            _string = 0;
         else {
            _string = new char[ _size + 1 ];
            strcpy( _string, rhs._string );
         }
   }

           new, 
   delete,   String   .   
    -  ,  
    ,     . (.  7 
  .)       (~)  
.     String.     
 delete,   ,   :

   inline String: :~String() { delete [] _string; }

          
 this.
     :

   String namel( "orville" ), name2( "wilbur" );
   namel = "Orville Wright";

                                                          ++   141

this  ,   name1    
.
   this     ,     . 

   ptr->size();
   obj[ 1024 ];

  size()  this  ,   ptr.  
  this   obj.  this ( *this),
   . ( this     13.4.)

   inline String& String::operator=( const char *s )
   {
      if ( ! s ) {
         _size = 0;
         delete [] _string;
         _string = 0;
     }
     else {
        _size = str1en( s );
        delete [] _string;
        _string = new char[ _size + 1 ];
        strcpy( _string, s );
   }
   return *this;
   }

           :
 ,        ,  
 .    ,     

this:
if ( this != &rhs ) {

      String    :

                                                           ++   142

   inline String& String::operator=( const String &rhs )
   {
      if ( this != &rhs ) {
         delete [] _string;
         _size = rhs._size;
         if ( ! rhs._string )
            _string = 0;
         else {
            _string = new char[ _size + 1 ];
            strcpy( _string, rhs._string );
         }
      }
      return *this;
   }

             Array,
     2.3:

   #include <cassert>

   inline char& String::operator[] ( int elem )
   {
      assert( elem >= 0 && elem < _size );
      return _string[ elem ];
   }

           ,    . (
      15.2.   20.4  20.5  
      iostream.)    
   4095 . setw()   ,   
      1,   ,   
    inBuf. (  20  setw()
 .)     
  :

   #include <iomanip>

   inline istream& operator>>( istream &io, String &s )
   {
      //  : 4096 
      const int 1imit_string_size = 4096;
      char inBuf[ limit_string_size ];
      // setw()    iostream
     //       1imit_string_size-l
     io >> setw( 1imit_string_size ) >> inBuf;
     s = mBuf; // String::operator=( const char* );
     return io;
   }

                                                            ++   143

           String. 
 operator<<   -,       
 _string.     :  operator<<
  String,    friend (
    15.2),    (inline)
     .       : c_str()
     .   
  :

   inline ostream& operator<<( ostream& os, const String &s )
   {
      return os << s.c_str();
   }

      ,   String.   
        ,     "the"
 "it"    .

                                                               ++   144
   #include <iostream>
   #inc1ude "String.h"
   int main() {
      int aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0,
         theCnt = 0, itCnt = 0, wdCnt = 0, notVowel = 0;

      //  "The"  "It"
      //     operator==( const char* )
      String but, the( "the" ), it( "it" );

      // operator>>( ostream&, String& )
      while ( cin >> buf ) {
         ++wdCnt;
              
         // operator<<( ostream&, const String& )
         cout << buf << ' ';
             
         if ( wdCnt % 12 == 0 )
            cout << endl;
                 
         // String::operator==( const String& ) and
         // String::operator==( const char* );
         if ( buf == the | | buf == "The" )
            ++theCnt;
         else
            if ( buf == it || buf == "It" )
                ++itCnt;
                  
           // invokes String::s-ize()
           for ( int ix =0; ix < buf.sizeO; ++ix )
           {
              // invokes String:: operator [] (int)
              switch( buf[ ix ] )
              {
                 case 'a': case 'A': ++aCnt; break;
                 case 'e': case 'E': ++eCnt; break;
                 case 'i': case 'I': ++iCnt; break;
                 case 'o': case '0': ++oCnt; break;
                 case 'u': case 'U': ++uCnt; break;
                 default: ++notVowe1; break;
              } // switch( buf[ ix ] )
          }  //for
       }  //while

       // operator<<( ostream&, const String& )
       cout << "\n\n"
              << ": " << wdCnt << "\n\n"
              << "the/The: " << theCnt << '\n'
              << "it/It: " << itCnt << "\n\n"
              << ": " < <notVowel << "\n\n"
              << "a: " << aCnt << '\n'
              << "e: " << eCnt << '\n'
              << "i: " << ICnt << '\n'
              << "o: " << oCnt << '\n'
              << "u: " << uCnt << endl;
   }

    :      ,  
    (        6).  
 :


                                                         ++   145

   Alice Emma has long flowing red hair. Her Daddy says when the
   wind blows through her hair, it looks almost alive, 1ike a fiery
   bird in flight. A beautiful fiery bird, he tells her, magical but
   untamed. "Daddy, shush, there is no such thing," she tells him, at
   the same time wanting him to tell her more. Shyly, she asks,
   "I mean, Daddy, is there?"

   : 65
   the/The: 2
   it/It: 1
   : 190
   a: 22
   e: 30
   i: 24
   : 10
   u: 7

                                        3.26

           
.        -
,       2.3. ,    .

                                        3.27

      ,      b, d, f, s,
t.

                                         3.28

    -,      
String,   :

   class String {
   public:
     // ...
     int count( char ch ) const;
     // ...
 };

                                         3.29

       (+) ,      
     String.   :

   class String {
   public:
      // ...
      String operator+( const String &rhs ) const;
      // ...
   };
