#include<stdio.h>
class test2
{
public:
void testFunc()
{
printf("test");
}
test2(){}
~test2(){}
};
class test1 : test2
{
public:
test1(){
link = new test2();}
~test1(){
delete link;
link = NULL;
}
test2* link = NULL;
private:
};
int main()
{
test1 *ptr = new test1();
delete ptr;
ptr->link->testFunc();
return 0;
}
I want to delete the test2 object after calling the deconstructor of test1. Yet, Im still able, after calling delete and setting link to NULL, to call the member function "testFunc" and print "test" with the link pointer. Why is this possible?