home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16401 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  1.1 KB

  1. Path: sparky!uunet!ogicse!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!meibm31.cen.uiuc.edu!pl2440
  2. From: pl2440@meibm31.cen.uiuc.edu (Paul Jay Lucas)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Simple question: class objects & pointers
  5. Message-ID: <Bxu2zr.F1q@news.cso.uiuc.edu>
  6. Date: 17 Nov 92 00:07:02 GMT
  7. Article-I.D.: news.Bxu2zr.F1q
  8. References: <1992Nov16.162130.11475@cis.ohio-state.edu>
  9. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  10. Distribution: usa
  11. Organization: University of Illinois at Urbana
  12. Lines: 23
  13.  
  14. In <1992Nov16.162130.11475@cis.ohio-state.edu> beery@clipper.cis.ohio-state.edu (brian david beery) writes:
  15.  
  16. >I am new to C++, and have a question regarding pointers and class objects:
  17. >The following code:
  18. >class cl_object
  19. >{public:
  20. >  int value;
  21. >}
  22. >generic_function(cl_object *o)
  23. >{
  24. >  *o.value=0;
  25. >}; 
  26.  
  27.     o->value = 0;    // shorthand for: (*o).value = 0;
  28.  
  29.     Look at the precedence of * and . (dot).  If you don't have
  30.     one, I'd suggest a good C++ book.
  31.  
  32.     BTW, public data are considered bad by some people.
  33. -- 
  34.     - Paul J. Lucas                University of Illinois    
  35.       AT&T Bell Laboratories        at Urbana-Champaign
  36.       Naperville, IL            pjl@cs.uiuc.edu
  37.