home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!sumax.seattleu.edu!thebes!manutius!garyp
- From: garyp@manutius.UUCP (Gary Powell)
- Newsgroups: comp.lang.c++
- Subject: Re: Reference vs. Pointer
- Message-ID: <731@manutius.UUCP>
- Date: 21 Jan 93 17:37:18 GMT
- References: <1993Jan15.175541.247@base> <1993Jan17.232403.5936@microsoft.com>
- Reply-To: garyp@manutius (Gary Powell)
- Distribution: na
- Organization: Aldus Corporation, Seattle WA
- Lines: 39
-
-
- One other thing references do well is when you are overloading operators
- and attempting you can give oject symantics while not putting objects on the
- stack. ie:
-
- class foo {
- public:
- friend foo &operator/(foo &lhs,foo &rhs);
- // rest of definition....
- }
-
- foo & operator/(foo &lhs, foo &rhs)
- {
- foo result;
-
- // Do result = lhs/rhs;
-
- .
- .
- .
- return result;
- }
-
- Which allows you to write;
-
- {
- foo a,b(inital value),c(initial value);
-
- a = b/c;
-
- }
-
- PS.
- Be sure and write the copy constructor, and overload the assignment operator
- too.
- Gary Powell ------------+ Internet: garyp@aldus.com
- c/o Aldus Corporation | uunet: manutius!garyp@uunet.uu.net
- 411 1st Ave South | uucp: camco!manutius!garyp
- Seattle, WA 98104 USA | Voice: (206) 622-5500
-