destructor problems

From: James Connell (jconnell_at_gci.net)
Date: 03/31/04


Date: Wed, 31 Mar 2004 06:35:22 -0900

Hi guys,

just as i thought i was gettng a handle on c++ this pops up.

i'm working on a project that derives a class from a base class ( it's
an aftermarket lib so i only have the headers to work with). oin the new
class i need at add a couple pointers to a couple of other classes in
the lib and , if needed, create them with 'new'. now it's my
understanding that i'll need to destroy these in the destructor for my
class. and there's the rub - i can't declare a destructor for myclass ?!?
i keep getting and error - Virtual function 'TMyClass::~TMyClass()'
confilts with base class 'TAncestor'.

inline virtual ~TAncestor(void) { }

is the base destructor, and my Dtor is

TMyClass::~TMyClass(void)
{
    if(BitMap) delete BitMap;
    if(Control) delete Control;
}

Ctors are
virtual TAncestor(TBaseAncestor* x);

TMyClass::TMyClass() : TAncestor(NULL),Control(NULL),
             FState(NORMAL),BitMap(NULL)
  {
  }

ive never had a problem useing null for the base of Ancestor any other
time ( but i haven't inherited from this base before) but could that be
causeing the grief?

--JC



Relevant Pages

  • Re: destructor problems
    ... > i'm working on a project that derives a class from a base class (it's ... The base destructor is probably: ... I presume from what you say, that 'TAncestor' is a class written ... Don't make your own classes have a virtual constructor (unless you ...
    (alt.comp.lang.learn.c-cpp)
  • Re: virtual destructor revisted
    ... > sure the destructor of Derived class will be invoked when a pointer of ... you want class Base to have at least one virtual function (so that you can ... functions (including destructor) and document that fact. ...
    (comp.lang.cpp)
  • Re: Tool for troubleshooting R6025 error in VC++
    ... >> Hence I don't think it is problem with virtual function call. ... > Usually pure virtual function calls occur when somebody is trying to call ... > function from constructor or destructor of a class (explicitly or ...
    (microsoft.public.vc.mfc)
  • Unresolved external symbol "void __cdecl __CxxCallUnwindDtor
    ... I have created a Visual C++ class library project with two classes named Base and Derived where ... This does not happen when there is no detructor in Base or when there is a destructor in Base ... but no class derives from Base or when I put this code into a Visual C++ console application ... using namespace System; ...
    (microsoft.public.dotnet.languages.vc)
  • Re: COMPILE!
    ... >typedef int HKEY; ... There's your problem - calling a virtual function from a destructor ... *vtable pointer updated to point to base class vtable* ...
    (comp.lang.cpp)