🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50750

Overriding superclass (non-virtual) functions in G++1.40.3

#50750
From: Alan Ezust
Date: Thu, 19 Aug 1993 18:43
24 lines
1667 bytes
I am reading code written by someone else in g++1.40.3.

This person wrote a class DList, which did not inherit anything,
and a class SDList which inherited from DList.

Both classes have this function:

DList *appendList (Dlist *pdl);

which do different things. I assume the one declared inside SDList
overrides the one in DList, as it appears to behave that way.

so my question: in normal C++, the appendList function should be declared
as virtual in DList (the superclass), while it is NOT declared virtual in
this particular program I am looking at... In g++ 1.40.3, are virtual
declarations OPTIONAL or something? I would have expected some sort of
compiler error from this code... Would there be a difference if I declared
the superclass function as virtual?

-- 
| Alan Ezust           ezust@iro.umontreal.ca      Montreal, Quebec, Canada |
|---------- Universite de Montreal    Departement d'informatique -----------|
        "Non-determinism means never having to say you're wrong."
Technical Details
Message-ID: <1993Aug19.184342.21174@IRO.UMontreal.CA>
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!spool.mu.edu!bloom-beacon.mit.edu!mcrcim.mcgill.edu!sifon!CC.UMontreal.CA!IRO.UMontreal.CA!ezust

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,144a33d79ae23dbb,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-08-19 12:10:22 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!spool.mu.edu!bloom-beacon.mit.edu!mcrcim.mcgill.edu!sifon!CC.UMontreal.CA!IRO.UMontreal.CA!ezust
From: ezust@IRO.UMontreal.CA (Alan Ezust)
Subject: Overriding superclass (non-virtual) functions in G++1.40.3
Message-ID: <1993Aug19.184342.21174@IRO.UMontreal.CA>
Sender: news@IRO.UMontreal.CA
Organization: Universite de Montreal, Canada
Date: Thu, 19 Aug 1993 18:43:42 GMT
Lines: 24