CPP   10

const cpp

Guest on 5th July 2022 05:09:31 PM

  1. // file: const.cpp
  2.  
  3.  
  4. int main()
  5. {
  6.    int       x = 2;  // same as: const int x = 5;
  7.    int       y = 3;
  8.    int const z = 4;
  9.    int const w = 5;
  10.    
  11.    int       *       p00 = &x;
  12.    int       * const p01 = &y;
  13.    int const *       p10 = &z;
  14.    int const * const p11 = &w;
  15.    
  16.    int       *       *       pp000 = &p00;
  17.    int       *       * const pp001 = &p00;
  18.    int       * const *       pp010 = &p01;
  19.    int       * const * const pp011 = &p01;
  20.    int const *       *       pp100 = &p10;
  21.    int const *       * const pp101 = &p10;
  22.    int const * const *       pp110 = &p11;
  23.    int const * const * const pp111 = &p11;
  24.    
  25.    *p00 = 6;
  26.    *p01 = 7;
  27.    // *p10 = 8;
  28.    // *p11 = 9;
  29.    
  30.    // pp111 = &p10;
  31.    pp110 = &p10;
  32.    // **pp110 = 6;
  33.    
  34.    
  35.    return 0;
  36. }

Raw Paste


Login or Register to edit or fork this paste. It's free.