Classes and variables help?

I have a variable called SDL_Renderer* gRenderer. This variable is stated in private, in a header file called initialization. There is a function also declared public within the header file.

bool Initial();

the Initial function changes the value of gRenderer from NULL, to something different.

I want to access the different variable from a different class, in a different function. Whenever I use friend classes, it returns me the value NULL.

My Main Function
1
2
3
4
5
6
7
8
  int main(int argc, char *argv[])
{
        Initialize mainkey;
        mainkey.Initial();

        Overworld key;

    }


Part of the function Initial that changes the gRenderer value.
1
2
3
4
5
6
7
 gRenderer = SDL_CreateRenderer( gWindow, -1, SDL_RENDERER_ACCELERATED );
            if( gRenderer == NULL )
            {
                printf("Renderer Failed to be created! Check Initialize Function!! SDL Error: %s\n", SDL_GetError() );
                InitialStart = false;
            }
            


and the Function that wants to use the gRenderer
1
2
3
4
5
6
7
 Initialize bgkey;
            //Create texture from surface pixels
            newBG = SDL_CreateTextureFromSurface( bgkey.gRenderer, LoadedImage );
                if( newBG == NULL )
                {
                    printf("Unable to create texture properly! SDL Error", path.c_str(), IMG_GetError() );
                }


I can tell gRenderer is returning NULL because of the if statement from the function that wants to access gRenderer, what do I do?
Topic archived. No new replies allowed.