I have the following problem. I create a class, and store the pointer to that class in an other class. Upon creating, everything is OK. However, a single step later it seems that the class has disappeared.
I've written a very simple test scenario here:
#include <iostream>
using namespace std;
class test
{
public:
test();
bool ok;
};
test::test()
{
ok = false;
}
class func
{
public:
func();
void check();
test *pTest;
};
func::func()
{
test temptest = test();
cout << temptest.ok << endl;
pTest = &temptest;
cout << pTest->ok << endl;
}
void func::check()
{
cout << pTest->ok << endl;
};
int main( int argc, char *argv[] )
{
func mFunc = func();
// what happens here
mFunc.check();
}
The above program outputs the following:
0
0
204
From 204 I'd guess that somehow the class I've created before has disappeared.
Can you tell me what is happening and why?