home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15946 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  2.7 KB

  1. Path: sparky!uunet!mcsun!uknet!warwick!bham!bhamvx!mccauleyba
  2. From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: c++ & c+++
  5. Message-ID: <1992Nov8.235940.1@vax1.bham.ac.uk>
  6. Date: 8 Nov 92 23:59:40 GMT
  7. References: <1992Nov8.222637.5773@nmsu.edu>
  8. Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
  9. Organization: University of Birmingham
  10. Lines: 48
  11.  
  12. In article <1992Nov8.222637.5773@nmsu.edu>, willittl@spock.NMSU.Edu (William  Little) writes:
  13. > The books I bought were for beginners, and didn't tell me 
  14. > much.  I went through them in a couple hours, and came up
  15. > with some questions in areas they didn't cover.
  16. Get the ARM (Annotated reference manual) I've never seen it but
  17. everyone else sears by it! (I use "The C++ Prog.Lang.Edn.2" also by
  18. the man himself which is probably not quite as good).
  19.  
  20. > class::variable
  21. > class::function()
  22. The :: operator is used to refer to something inside a class without
  23. refering to any object of the class. In this case your probably thinking of
  24. static members which are just ordinary global functions or variables that
  25. happen to be owned by the class. class:: might just as well be class_ for
  26. most purposes (a simplistic way of looking at things and one I would not
  27. recomend to anyone but a C convert (I learnt C the odd way by leaning C++
  28. then being told what I _couldn't_ do))
  29. Because static members belong to the class they behave like members wrt
  30. privacy.
  31.  
  32. >   [Class declaration with some inline and some out-of-line member fns]
  33.  
  34. > They created function3 inside the test class, yet defined
  35. > the code for it out of the class definition, and used those
  36. > nasty ::'s that confuse me so well.
  37. For big member functions one puts only the prototype in the class declaration
  38. (and hence in the header file) with the definition in a source file.
  39. For trivial member functions one gives the whole definition and the compiler
  40. will attempt to compile them inline (and optimize them out) when appropriate.
  41. > What do the ::'s do??
  42. Let's you refer to a member of a class while you're lexical outside the
  43. class. Thus sice funtions3's prototype was inside the class definition
  44. it didn't need a prefix (although it's not strictly wrong to give it one)
  45. but function3's definition needs its full name including the class name
  46. part.
  47.  
  48. What I've said here is a gross simplification of the full story. If you
  49. think the :: is confusing now just wait till you start playing with nested
  50. classes, derived classes and virtual base classes ;->
  51. -- 
  52.     \\   ( )  NO BULLSHIT! from BAM (Brian McCauley)
  53.  .  _\\__[oo 
  54. .__/  \\ /\@  E-mail: B.A.McCauley@bham.ac.uk
  55. .  l___\\        Fax: +44 21 625 2175
  56.  # ll  l\\     Snail: 197 Harborne Lane, Birmingham, B29 6SS, UK
  57. ###LL  LL\\     ICBM: 52.5N 1.9W
  58.  
  59.