🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #300

virtual strangeness

#300
From: P{r Emanuelsson
Date: Thu, 27 Jul 1989 17:39
34 lines
1102 bytes
What about this?

class base {
  public:
  char *data;
  virtual void operator=(const base& in) {
    printf("NYI!\n");
  }
};

class derived : public base {
  public:
  void operator=(base& in) {
    data = in.data;
  }
};

main()
{
  base *e = new derived;
  base *m = new derived;

  *e = *m;
}

With cfront 1.2 this works as (I) expected. With G++ it prints "NYI!".
Why is this? Neither compiler complains about anything.

Machine: Sun386i
--
"Don't think; let the machine do it for you!"
                                   -- E. C. Berkeley
Dept. of Electrical Engineering	                         pell@isy.liu.se
University of Linkoping, Sweden	                    ...!uunet!isy.liu.se!pell
Technical Details
Message-ID: <8907271739.AA02653@rainier.isy.liu.se>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ISY.LIU.SE!pell

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ISY.LIU.SE!pell
From: pell@ISY.LIU.SE (P{r Emanuelsson)
Newsgroups: gnu.g++.bug
Subject: virtual strangeness
Message-ID: <8907271739.AA02653@rainier.isy.liu.se>
Date: 27 Jul 89 17:39:46 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 34