Jump to content

Class Destructors Not Being Called


Recommended Posts

Hi,

There seems to be a problem with the class destructors,

they do not seem to be called when the class loses scope,

in fact although they do not cause a compiler error, they

do not appear to be compiled into the source code at all.

 

Do you have another destructor "declaration name" that needs

to be used instead of "tilde" (~) + "class name" ??

 

 

Regards... Tim

 

#include <system.h>

class Test
{
 Test();
~Test();

int c;
};

Test::Test()
{
c = 0;
}

Test::~Test()
{
c = 1; // This Destructor member is not called
}

ScopeTestFunction()
{
class Test t;
}


void main()
{
int a = 0;

ScopeTestFunction();

a = 1;
a = 2;
}

Link to post
Share on other sites
  • 1 month later...

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...