Original Post
Hi all Just when you think you got pointers 100% down, something new comes up. I am using a get function to get the address of variables from an class/object, the problem is the addresses arnt being returned...heres the example:
Viewport *vp_1 = NULL;
Viewport *vp_2 = NULL;
Viewport *vp_3 = NULL;
Viewport *vp_4 = NULL;
mainFrame->GetViewports(vp_1, vp_2, vp_3, vp_4);
The function GetViewports is supposed to return the addresses of the 4 viewports, which are themselves class variables (infact they are pointers to viewports). The implementation is:
void MainFrame::GetViewports(Viewport *v1,Viewport *v2,Viewport *v3,Viewport *v4)
{
v1 = viewPort_1; //viewPort_1 is a class variable of MainFrame here
v2 = viewPort_2;
v3 = viewPort_3;
v4 = viewPort_4;
return;
}
What that is supposed to do is copy the address of viewPort_1 (which is a pointer itself) to v1, etc. Using gdb, this works fine... The viewports are created in the MainFrame::MainFrame() constructor:
Viewport *viewport_1 = new Viewport(etc...);
Viewport *viewport_2 = new Viewport(etc...);
Viewport *viewport_3 = new Viewport(etc...);
Viewport *viewport_4 = new Viewport(etc...);
My problem is that vp_1, vp_2, vp_3, vp_4 remain NULL after the call to GetViewports (i can see in the debugger)...and I cant see why? Any ideas?