Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!think.com!huxley!glenn From: glenn@huxley.huxley.bitstream.com (Glenn P. Parker) Newsgroups: comp.lang.c++ Subject: Re: friend operator +(l,r) vs. operator +(r) Message-ID: Date: 27 Nov 90 23:11:42 GMT References: <11759@hubcap.clemson.edu> <1990Nov21.053431.22340@actrix.co.nz> Sender: glenn@huxley.UUCP Reply-To: (Glenn Parker) Organization: Bitstream, Inc. Lines: 26 In-reply-to: fox@allegra.att.com's message of 22 Nov 90 13:52:57 GMT In article , fox@allegra.att.com (David Fox) writes: > Another difference is that the member version can be virtual, while > the friend version cannot. Is this really a big difference? Global overloading can make operator+ work very much like a virtual function. If the friend function is declared as: class A { // ... friend A operator+ (const A& left, const A& right); }; Then classes derived from A can use operator+ automatically, *or* they can override it as follows: class B : public A { // ... friend B operator+ (const B& left, const B& right); }; -- Glenn P. Parker glenn@bitstream.com Bitstream, Inc. uunet!huxley!glenn 215 First Street BIX: parker Cambridge, MA 02142-1270