SDL_rect function

Hello there, im sitting here doing pong using SDL and I have found myself in a little pickle.

I have some variables in my player class that I need to be calling in my core.cpp.
The member variables are private and therefor not accesable, what im trying to do is make a function that will return the rect of my object; this is where I get problems.

I have a variable in my entity header that is a SDL_rect, my ball class inherits my entity header and can get a hold of the sdl_rect variable.

What im trying to do is just a function that will return a sdl_rect.


   SDL_rect* mBallRect;

SDL_rect* getRect() {return mBallRect;}

There is the stuff.
I'm trying to set values to getRect in Ball::inititalize(), for instance
getRect()->x = 200;

But it will return a null pointer, how do I not make it a null pointer while doing it this way? Maybe this way is retarded, I don't know.

and yeah, I do this because I don't want my variables in Ball.cpp to be public.

SDL_BlitSurface takes a SDL_rect* as a last parameter, as the last parameter I want to be able to type in mBall->getRect()

Hope it's not to hard to understand what im after ^^ Cheers.
Topic archived. No new replies allowed.