🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #85

Re: virtual operator+

#85
From: Josh Sebastian
Date: Fri, 17 May 2002 05:13
24 lines
2059 bytes
On Thu, 16 May 2002 21:17:53 GMT, "Christopher Deli"
<christopher@delinfo.com> wrote:

>Hello!
>
>I have a problem which I'd need some help with, please.
>If I have one class A which is inherited by another class B i.e. class B :
>public class A and I would like to make a virtual operator+ in both class A
>and B so I could do the following:
>A *a, *b, *c
>a = new B(...)
>b = new B(...)
>c = new B(...)
>*c = *a + *b
>So I make a pointer of type A which points on an objekt of type B. For that
>I'd need a virtual operator+ but I have no idea how to make it. Please help!
>The source code of a program which has the similar situation would be
>perfekt! Thanks!

If you did this, then *a + *b could mean something (very) different
from *b + *a. That's not a good idea, generally. Perhaps you shouldn't
use an overloaded operator, in this circumstance.

Josh
Technical Details
Message-ID: <rg49eusfujq9l0nq0m5dimtbenu36m0lor@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!cox.net!news2.east.cox.net.POSTED!53ab2750!not-for-mail
References: <5mVE8.38287$n4.8427350@newsc.telia.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 114592,e2ff40a616ce87ab
X-Google-Attributes: gid114592,public
X-Google-Thread: 10d4ba,e2ff40a616ce87ab
X-Google-Attributes: gid10d4ba,public
X-Google-Thread: 109fba,e2ff40a616ce87ab
X-Google-Attributes: gid109fba,public
X-Google-ArrivalTime: 2002-05-16 22:13:24 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!cox.net!news2.east.cox.net.POSTED!53ab2750!not-for-mail
From: Josh Sebastian <curien@cox.net>
Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++
Subject: Re: virtual operator+
Message-ID: <rg49eusfujq9l0nq0m5dimtbenu36m0lor@4ax.com>
References: <5mVE8.38287$n4.8427350@newsc.telia.net>
X-Newsreader: Forte Agent 1.91/32.564
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 24
Date: Fri, 17 May 2002 05:13:22 GMT
NNTP-Posting-Host: 68.10.124.242
X-Complaints-To: abuse@cox.net
X-Trace: news2.east.cox.net 1021612402 68.10.124.242 (Fri, 17 May 2002 01:13:22 EDT)
NNTP-Posting-Date: Fri, 17 May 2002 01:13:22 EDT
Organization: Cox Communications