From 6879827811403526193
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fe40a3780453cbe2,start
X-Google-Attributes: gidf78e5,public
From: rac@intrigue.com (Robert Coie)
Subject: Virtual operator=
Date: 1995/05/19
Message-ID: <rac-1905951238280001@intrigue.intrigue.com>#1/1
X-Deja-AN: 102964202
organization: Intrigue Corporation
newsgroups: comp.std.c++

Apologies to sites who receive two versions of this, previous post
cancelled due to egregious error in sample code.

Given the note in verse 2 of 13.5.3,

Note: for a derived class D with a base class B for which a virtual copy
assignment has been declared, the copy assignment operator in D does not
override B's virtual copy assignment operator.

I would assume that:

struct A { virtual A & operator=( const A & ); };
struct B : A { B & operator=( const A & ); };

static void f( A & a )
{
   A * a2 = new A;
   a = *a2;    // calls A::operator= ???
}

int main()
{
   B  b;
   f( b );
}

If this is the case, and B::operator= is not invoked in the commented
line, what is the point of virtual copy assignment operators?

Robert Coie                              rac@intrigue.com
Implementor, Intrigue Corporation     AppleLink: INTRIGUE



