home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11528 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  1.0 KB

  1. From: wright@hpcc01.corp.hp.com (Jeff Wright)
  2. Date: Fri, 24 Jul 1992 19:45:52 GMT
  3. Subject: Re: Programming guidelines: naming of data members?
  4. Message-ID: <1000003@hpcc01.corp.hp.com>
  5. Organization: HP IC Business Div Palo Alto
  6. Path: sparky!uunet!usc!sdd.hp.com!hpscdc!hplextra!hpcc05!hpcc01!wright
  7. Newsgroups: comp.lang.c++
  8. References: <1992Jul17.204822.9087@bcrka451.bnr.ca>
  9. Lines: 23
  10.  
  11. > 1.  What conventions do you like for naming private and protected data
  12. >     members?  Why?
  13. > 2.  What naming conventions do you use for get/set functions?
  14.  
  15. I investigated this a couple of months ago and decided to go with the
  16. following approach:
  17.  
  18.    class Example
  19.    {
  20.    public:
  21.       void    num(int aNum) { theNum = aNum; }
  22.       int    num() const { return theNum; }
  23.    private:
  24.       int    theNum;
  25.    };
  26.  
  27. It's a little more verbose than underscores or single-letter prefixes,
  28. but I like it pretty well.  Plus you don't have so many "gets" and "sets".
  29.  
  30.  
  31. --Jeff Wright                  HP IC Business Division--Palo Alto
  32.   wright@hpctgrd.hpl.hp.com               (HPtelnet/415) 857-5351
  33.