So, I've got this class in SDL Player that has, among other things, an SDL_Texture* to hold an image that represents the player on the screen. I'd assume it's good practice to do get() and set() functions for the class; but because textures are handled via pointers, when I write a get() function I end up returning a pointer to an internal resource; which isn't good practice I hear as it "breaks" encapsulation. Any way to get around this?
Normally its OK if you just make it const-correct, then they can't modify your image without setting it. Get/Set functions should be avoided if possible, normally - encapsulate them within a function, though in this case it makes sense. Change your definition to be similar to this: