This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: defining a pure virtual
- To: Benoit Hudson <bh at techhouse dot brown dot edu>
- Subject: Re: defining a pure virtual
- From: Phil Edwards <pedwards at disaster dot jaj dot com>
- Date: Thu, 31 Aug 2000 16:51:38 -0400
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <20000831162510.C21731@techhouse.brown.edu>
On Thu, Aug 31, 2000 at 04:25:10PM -0400, Benoit Hudson wrote:
> I've just noticed that defining a pure virtual function works.
There's nothing wrong with defining a pure virtual function. It's perfectly
valid code.
Just because a function is pure virtual doesn't mean that there's no
definition; it just means that the class is abstract and cannot be
instantiated. Defining PVs is a useful technique for providing default
implementations of functions, for example, that derived classes only get
if they ask for.
Also, a pure virtual destructor /has/ to be defined.
--
pedwards at disaster dot jaj dot com | pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools. Fools are protected by more capable fools.