Re: Call to a virtual method crashes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Doug Harrison [MVP] (dsh_at_mvps.org)
Date: 02/15/05


Date: Mon, 14 Feb 2005 21:34:51 -0600

Frank Hickman [MVP] wrote:

>You've changed the functions virtualness. You need to declare them virtual
>in both the base and derived class.

It doesn't matter. For better or worse, the following are equivalent:

struct X
{
   virtual void f();
};

struct Y1 : X
{
   virtual void f();
};

struct Y2 : X
{
   void f();
};

Both Y1::f and Y2::f override X::f.

-- 
Doug Harrison
Microsoft MVP - Visual C++


Relevant Pages

  • Re: the address returned from "new" statement is 4-byte aligned?
    ... Mihai Nita [Microsoft MVP, Windows - SDK]http://www.mihai-nita.net ... I think the #pragma packis useless to solve my problems, ... can define some static members. ... #pragma packonly controls how fields are packed in an individual class or struct. ...
    (microsoft.public.vc.mfc)
  • Re: the address returned from "new" statement is 4-byte aligned?
    ... Mihai Nita [Microsoft MVP, Windows - SDK]http://www.mihai-nita.net ... I think the #pragma packis useless to solve my problems, ... can define some static members. ... #pragma packonly controls how fields are packed in an individual class or struct. ...
    (microsoft.public.vc.mfc)
  • avoid cast to derived
    ... userBase objects, ... struct Base{virtual void method=0;}; ... virtual void user1(Base& obj){obj.method;} ...
    (comp.object)
  • Maximizing speed of a switch block
    ... We have a critical loop which looks like this: ... virtual void doIt; ... struct allMyVars ... void action_1(X*, allMyVars* v) ...
    (microsoft.public.vc.language)
  • Re: Why are there no covariant return types?
    ... Stoitcho Goutsev [C# MVP] ... > Stoitcho Goutsev wrote: ... > virtual void gconst { ...
    (microsoft.public.dotnet.languages.csharp)