www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/18/11:49:59

From: G DOT DegliEsposti AT ads DOT it
To: djgpp AT delorie DOT com
Message-ID: <C12565CB.005BD345.00@vega.ads.it>
Date: Wed, 18 Mar 1998 17:48:11 +0100
Subject: Re: Run-time error: pure virtual function called
Mime-Version: 1.0




>> > the message "Pure virtual function called" (using DJGPP of course, gcc
>> > 2.7.2.1).
>>
>> The most obvious way how to get this message is to call virtual function
>> from constructor or destructor of base class when this virtual function
is
>> redefined in inheritted class
>
>Why is this a runtime error? Can't the compiler locate this bug?

No it can't because when it is compiling the function call, the compiler
can't know if the pure virtual function will be overridden in some
descendent
class.

You can think like if it was a call to a function pointed by some pointer,
how
could you know at compile time if at runtime it will be NULL or point to a
valid
function? (C++ purists forgive me for this example :-)

ciao
  Giacomo


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019