I have the following class (I stripped out all the non relevant bits)
class PACKAGE TLicCustomDialog : public TCustomApplicationEvents
{
protected:
bool __fastcall DialogStart (bool genEntries = false);
int __fastcall DialogEnd (void);
public:
__fastcall TLicCustomDialog (TComponent *owner);
virtual __fastcall ~TLicCustomDialog (void);
virtual int __fastcall Execute (void);
int __fastcall GenerateEntries (void);
int __fastcall GenerateTransEntries (void);
bool __fastcall Show (void);
int __fastcall Hide (void);
int __fastcall Close (void);
};
with the following implementation
int __fastcall TLicCustomDialog::Execute (void)
{
if (! DialogStart ()) return 0;
FDialogForm->ShowModal ();
return FDialogResult;
}
int __fastcall TLicCustomDialog::GenerateTransEntries (void)
{
if (! DialogStart ()) return 0;
FDialogForm->ShowModal ();
return FDialogResult;
}
As you can see, the implementation of both functions is identical (made that so on purpose, to demonstrate the problem, using copy/paste).
When I call Execute (), everything works as it should. When I call GenerateTransEntries (), the application crashes with "Pure virtual function called". And I'm at a loss as to why that is.
Even weirder, when I replace the body of GenerateTransEntries () with
int __fastcall TLicCustomDialog::GenerateTransEntries (void)
{
return Execute ();
}
then a call to GenerateTransEntries () doesn't crash, and does what was supposed to happen. I've tried to change the name of the GenerateTransEntries function. I've tried adding other functions, with varying different names (such as ABCDE) with the same body as the Execute () function. Each and every time, I get "Pure virtual function called" thrown in my face. The only time the code in that body doesn't crash, is when I call the Execute function itself.
What is causing the "Pure virtual function called" crash, because I really don't see it.
Connect with Us