Hey all,
I was playing around a little, and found out that this not only compiles, but the last call produces the result "5". I though a destructor destroys the class, so the program shouldn't be able to access the variable. Or is this accessing something out of bounds?Code:class Test {
int m_Val;
public:
void printVal() { cout << m_Val << endl; }
~Test() { m_Val = 5;}
Test(int val) { m_Val = val; printVal(); this->~Test(); }
};
int main()
{
Test(5);
Test a(10);
a.printVal();
return 0;
}
Cheers,
Gabe