I have a question about timing of call destructor. Please look at a script code and a output. //----------------------------------------------------------- //
script code
class ObjType
{
};
class HaveObj
{
HaveObj()
{
Print( "HaveObj::ctor\n" );
}
~HaveObj()
{
Print( "HaveObj::dtor\n" );
}
ObjType o;
};
class HaveHandle
{
HaveHandle()
{
Print( "HaveHandle::ctor\n" );
}
~HaveHandle()
{
Print( "HaveHandle::dtor\n" );
}
ObjType@ o;
};
void testCase1()
{
Print( "testCase1 start\n" );
{
HaveObj o;
}// call o.~HaveObj();
{
HaveHandle o;
}// not call o.~HaveHandle();
Print( "testCase1 end\n" );
}
void main()
{
testCase1();
}
//----------------------------------------------------------- //----------------------------------------------------------- //
output
testCase1 start
HaveObj::ctor
HaveObj::dtor
HaveHandle::ctor
testCase1 end
//----------------------------------------------------------- I expect that AngelScript call HaveHandle's destructor as well as HaveObj. Why don't AngelScript call HaveHandle's destructor as well as HaveObj?