derived method of abstract base class not getting invoked

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Charlie (cs_hart_at_yahoo.com)
Date: 08/31/04

  • Next message: Jochen Kalmbach: "Re: Virtual Address Space"
    Date: 31 Aug 2004 12:02:19 -0700
    
    

    I have the following

    Class Base {
      Base();

       virtual bool func(ListClass* tlist) =0;
    };

    Class Derived:public Base {
      Derived();
      ~ Derived();
      bool func(ListClass* tlist);
    }

    Code to invoke:
    ..
    Derived* ptr = new Derived();
    ptr->func(tlist);

    When I try to step into this function with the debugger I get a popup
    saying there is no source code available. If I look at the following
    code with disassembly window I see code like this:
            ptr->func(tlist);
    000002b4 mov eax,dword ptr [ebp-2Ch]
    000002b7 mov eax,dword ptr [eax]
    000002b9 mov esi,dword ptr [eax]
    000002bb mov edx,dword ptr [ebp-30h]
    000002be mov ecx,dword ptr [ebp-2Ch]
    000002c1 mov eax,esi
    000002c3 push 15B088h
    000002c8 call F9AF9FC0 <<<---- should be calling func but
    does not
    000002cd nop

    But for other methods, the source always has a load of a doubleword
    pointer as I would expect it would be looking up the method in a
    vector table.
            rList->otherFunc(tlist);
    000002f6 mov edx,dword ptr [ebp-30h]
    000002f9 mov ecx,dword ptr [ebp-34h]
    000002fc call dword ptr ds:[00836BB4h] <<< ----- calling
    otherFunc
    00000302 nop works fine

    Since this is debug compiled code I assume the compiler is responsible
    somehow. What I don't know is if there any options I'm using that
    might be causing this.
    I'm using .NET 2003 with the project defined as a console app.

    I should add that I had the same problem with the base destructor,
    even when I had it defined virtual. The derived class destructor was
    not getting invoked.
    I eliminated the destructor in the base .h file and the derived
    destructor started getting invoked at delete.


  • Next message: Jochen Kalmbach: "Re: Virtual Address Space"

    Relevant Pages

    • Re: delete in-place corresponding to placement new?
      ... > that comes to mind is to merely explicitly invoke the destructor. ... > capability is not available on a circa 1990 compiler. ... static void destroy(T *ptr) ...
      (comp.lang.cpp)
    • Re: Access Violation Releasing CComPtr
      ... You're using COM objects from DllMain (global destructors are ... TerminateProcess) which doesn't invoke ... msxml3.dll!DOMDocumentWrapper::`vector deleting destructor'() + ... hDllHandle=0x0dea0000, unsigned long dwReason=0x00000000, void * ...
      (microsoft.public.platformsdk.security)
    • Re: delete []
      ... when invoke delete, the destructor for each instance element of the ... , I malloc 10 bytes, and in the destructor of this class I will ... So the memory is balanced, ...
      (microsoft.public.dotnet.languages.vc)
    • Re: More on garbage collection
      ... >>> If you have to invoke a destructor, ... > That doesn't work if the object references itself, ... > point a reference-counted garbage collector will not know it should ...
      (comp.arch)
    • Re: How to hook up EventHandler or Delegate to UserControl thru Reflec
      ... code (to protect the IP in the source code), ... call Type.GetMethodmethod to retrieve the "SaveSettings" method, ... call the Invoke() method to invoke the "SaveSettings" method. ...
      (microsoft.public.dotnet.languages.csharp)