But I thought I was assigning their address to width and height pointers? so If they get destroyed when scope is left then what do i do? make them static?
Ok so I believe i figured it out, but please tell me if i'm wrong this seems to work, I tested it with and without de referencing the pointer and whne i de referenced it i got the numbers and when i didnt de reference it i got memory addresses. I think this is right but I just want to make sure.
#include <iostream>
#include <string>
usingnamespace std;
void SetWinParams(int *&width, int *&height)
{
int setWidth = 800;
int setHeight = 600;
width = &setWidth;
height = &setHeight;
}
void GetWinParams(int *&width, int *&height)
{
SetWinParams(width, height);
cout << width << " " << height << endl;
}
int main()
{
int *W;
int *H;
GetWinParams(W, H);
return 0;
}
Also
1 2 3 4
int *W;
int *H;
GetWinParams(W, H);
are pointers that don't point to anything, they are there solely so that i can have an argument to pass so I can use that function, so do I still need to initialize them? or at least set them to nullptr?