home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_12 / pugh / preproc.cpp < prev   
Encoding:
C/C++ Source or Header  |  1993-10-10  |  304 b   |  22 lines

  1. Listing 3
  2.  
  3. template <const int i>
  4. class INTEGER
  5.     {
  6. #if i == O
  7.     int val;
  8. #elif i == 1
  9.     char val;
  10. #elif i == 2
  11.     long val;
  12. #endif
  13.     };
  14.  
  15. should yield:
  16.  
  17. INTEGER<0> two_bytes;
  18. INTEGER<1> one_byte;
  19. INTEGER(2) four_bytes;
  20. //sizeof OPERATOR SHOWS THAT EVERY INSTANTIATION OF val IS OF 
  21. TYPE int.
  22.