From: Richard Dawe Newsgroups: comp.os.msdos.djgpp Subject: Re: Simple program. Strange results. Date: Fri, 29 Aug 2003 00:27:16 +0100 Lines: 57 Message-ID: <3F4E8FD4.AD6096D8@phekda.freeserve.co.uk> References: <200308280125 DOT h7S1PFP5020856 AT envy DOT delorie DOT com> NNTP-Posting-Host: 62.137.7.3 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news7.svr.pol.co.uk 1062113597 13177 62.137.7.3 (28 Aug 2003 23:33:17 GMT) NNTP-Posting-Date: 28 Aug 2003 23:33:17 GMT X-Complaints-To: abuse AT theplanet DOT net X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586) X-Accept-Language: de,fr To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello. Martin Stromberg wrote: > > DJ Delorie (dj AT delorie DOT com) wrote: > : > From what I can grasp, the asterisk symbol means the same thing. > : > Though I have yet to really grasp the proper place(s) and form(s) > : > for its usage. > > : Nope, asterisk is the inverse of ampersand. Ampersand takes the > : address of something, converting values into pointers that point to > : those values. Asterisks dereference pointers, turning pointers into > : the values they point to. > > Except when you declare/define variables and functions. Then * takes > the place where newbies would expect &. > > Then comes C++ where & is allowed in declarations/definitions too > (with some semantics I've never bothered to look up; I don't do C++). & is used to indicate that a variable is passed by reference in declarations/definitions in C++. E.g.: ---Start test.cpp--- #include #include using namespace std; void blargh (int& ref) { ref = 12; } int main (void) { int a = 5; blargh(a); printf("%d\n", a); return EXIT_SUCCESS; } ---End test.cpp--- No idea if that will compile. But if it does, it should print 12 when it runs. blargh modifies the int passed by reference. I like C++'s Standard Template Library (STL) - type-safe generic container classes. Saves you having to do generic list classes with macros in C, which is just horrible. (I strongly dislike C macros most of the time.) Bye, Rich =] -- Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]