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