markus3000
Programmer
- Aug 24, 2010
- 9
Hi, I tried the code in BCB 6 console app:
class Testclass
{
public:
double val;
//~Testclass(){};
};
#pragma argsused
int main(int argc, char* argv[])
{
Testclass * t1 = new Testclass;
t1->val = 0;
int s1 = sizeof(*t1);
delete t1;
int s2 = sizeof(*t1);
t1->val = 10;
cout<<t1->val;
}
There is no AV when trying to adjust t1->val = 10 !
Why is this?
Also, s1 and s2 both equal 8 bytes. why hasn't the memory been freed?
Also, although it's not in the contract, delete doesn't set t1 to NULL after deletion. Surely it should?
uncommenting //~Testclass(){}; makes no difference
class Testclass
{
public:
double val;
//~Testclass(){};
};
#pragma argsused
int main(int argc, char* argv[])
{
Testclass * t1 = new Testclass;
t1->val = 0;
int s1 = sizeof(*t1);
delete t1;
int s2 = sizeof(*t1);
t1->val = 10;
cout<<t1->val;
}
There is no AV when trying to adjust t1->val = 10 !
Why is this?
Also, s1 and s2 both equal 8 bytes. why hasn't the memory been freed?
Also, although it's not in the contract, delete doesn't set t1 to NULL after deletion. Surely it should?
uncommenting //~Testclass(){}; makes no difference