home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / std / cplus / 1090 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  983 b 

  1. Path: sparky!uunet!stanford.edu!rutgers!cmcl2!acf5!checker
  2. From: checker@acf5.NYU.EDU (checker)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: const and template parameters
  5. Message-ID: <1889@acf5.NYU.EDU>
  6. Date: 18 Aug 92 16:25:20 GMT
  7. References: <Bt5ECn.CtF@apollo.hp.com>
  8. Organization: New York University
  9. Lines: 25
  10.  
  11. vinoski@apollo.hp.com (Stephen Vinoski) writes:
  12. >    void tfunc(int *const arg);
  13. >with the argument actually being a const pointer to int.
  14. >The latter interpretation is exactly the same as the "const applied to
  15. >typedef" problem:
  16. >    typedef int *IntPtr;
  17. >    const IntPtr int_ptr;
  18. >Here, int_ptr is a const pointer to int (sometimes much to the
  19. >amazement of C++ novices :-)).
  20.  
  21. The `solution' is to write your declarations like this:
  22.  
  23. simple-type-name type-specifiers
  24.  
  25. that means
  26.  
  27. int const foo;
  28. instead of
  29. const int foo;
  30.  
  31. The only disadvantage of doing it this way is that hardly anybody does.
  32. I find it much clearer, especially when you get into complicated
  33. declarations.
  34.  
  35. Chris
  36.