benefits of a class in this case?
I'm all for using classes, but I have an object that I do not need any special functions to manipulate, doesn't/won't use inheritance, etc. It has 8 basic member variables (handful of int's, a byte, an LPDIRECTDRAWSURFACE7 and 2 LPRECTS).
The object is a tile section of the map. Basically the map is just a 2d array of this object. Here's a basic example:
Code:
class CTile
{
private:
int MapX;
int MapY;
int Width;
int Height;
byte Walkable;
LPRECT lprcSrc;
LPRECT lprcSize;
LPDIRECTDRAWSURFACE7 lpddsBitmap;
public:
CTile();
~CTile();
void SetMapX(int NewX);
int GetMapX();
//etc. etc. with member functions
};
The only member functions I'd need would be to populate or return the values of the member variables. Since they can all accept Rvalues I can just use a struct to represent my object without the overhead of a class.
ie:
Code:
struct Tile
{
int MapX;
int MapY;
LPRECT lprcSrc;
//etc. etc. etc.
};
Tile tile;
tile.MapX=0;
tile.MapY=0;
SetRect(tile.lprcSrc,0,0,32,32);
Is there any reason why I would be better off with a class in this case? It seems to me that a struct would work out fine without all the overhead of a class. None of the needed member functions would be more than 1 line of code, so using a class really wouldn't save me any typing, but would add to it with all the member function implementations.
Thanks in advance for any advice with this...