🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

1.32.0 base initialization ignores virtuality

#1859
From: Webster Dove
Date: Fri, 14 Apr 1989 04:08
43 lines
943 bytes
The following program prints
base
base
base
derived

and should (I think) print

base
base
derived
derived

This happens with cfront also.

Why?  (Please reply via mail)

// -*- C++ -*-

#include <stream.h>

class base
{
public: 
  virtual void foo() { cout << "base"; }
  base() { foo(); }
};

class derived : base
{
public:
  virtual void foo() { cout << "derived"; }
  derived() {};
};

main()
{
  base x;
  x.foo();

  derived y;	// Prints "base" should print "derived".
  y.foo();
}
Technical Details
Message-ID: <8904140408.AA08129@rocket.sanders.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!UUNET.UU.NET!rocket!dove

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!UUNET.UU.NET!rocket!dove
From: rocket!dove@UUNET.UU.NET (Webster Dove)
Newsgroups: gnu.g++.bug
Subject: 1.32.0 base initialization ignores virtuality
Message-ID: <8904140408.AA08129@rocket.sanders.com>
Date: 14 Apr 89 04:08:24 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 43