Re: Why static pure virtual method is not possible?

From: Mike Smith (mike_UNDERSCORE_smith_at_acm.DOT.org)
Date: 03/10/04


Date: Wed, 10 Mar 2004 17:09:10 -0500

Daniel LAUGT wrote:

> I have given only a simple example to express my problem.
> Now if my code is:
>
> void testFunction(Telegram *telegram)
> {
> if (telegram->getType() == LoginTelegram::getType())
> << specific login statements >>
> else if (telegram->getType() == LocationTelegram::getType())
> << specific location statements >>
> }
>
> Waht do you make?

Why not make TestFunction a virtual (optionally pure virtual) member
function of the base class Telegram, and get rid of the type checking
(or, rather, let the language do it for you)? *That's what it's there for.*

--
Mike Smith


Relevant Pages