pointer to pointer to heap
I'm not sure about this:
Does this work?
Code:
classA::classA(){
classA1 pa1 = new classA1;
classA2 pa2 = new classA2(pa1);
}
classA2::classA2(classA1* p){
m_pa1 = p; //Member-Variable
}
Later, I create a Thread that gets a pointer to m_pa1 and uses this pointer even after pa2 is destroyed.
threadFunctionBla(..){
classA2* pa2 = //get out of parameter//;
classA1* pa1 = pa2->m_pa1;
//do somwthing.
//classA2 is detroyed now by another Thread
pa1->doSomething(); //does this work? I get strange results.
i now it's confusing. if anybody sees any errors or wants to show a btter way, i'd be glad.