Answers to Self-Review Exercises

  1. E.1

    1. #.

    2. #elif, #else.

    3. #define.

    4. whitespace.

    5. #undef.

    6. #ifdef, #ifndef.

    7. Conditional compilation.

    8. assert.

    9. #include.

    10. ##.

    11. #.

    12. .

  2. E.2 (See below.)

    
     1  // exE_02.cpp
     2  // Self-Review Exercise E.2 solution.
     3  #include <iostream>
     4  using namespace std;
     5
     6  int main() {
     7     cout << "__LINE__ = " << __LINE__ << endl
     8          << "__FILE__ = " << __FILE__ << endl
     9          << "__DATE__ = " << __DATE__ << endl
    10          << "__TIME__ = " << __TIME__ << endl
    11          << "__cplusplus = " << __cplusplus << endl;
    12  }  // end main
    
    
    __LINE__ = 9
    __FILE__ = c:cpp4ech19ex19_02.CPP
    __DATE__ = Jul 17 2002
    __TIME__ = 09:55:58
    __cplusplus = 199711L
    
  3. E.3

    1. #define YES 1

    2. #define NO 0

    3. #include "common.h"

    4.  

      
      #if defined(TRUE)
         #undef TRUE
         #define TRUE 1
      #endif
      
    5.  

      
      #ifdef TRUE
         #undef TRUE
         #define TRUE 1
      #endif
      
    6.  

      
      #if ACTIVE
         #define INACTIVE 0
      #else
         #define INACTIVE 1
         #endif
      
    7. #define CUBE_VOLUME(x) ((x) * (x) * (x))

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset