>>but aren't classes much more accessible to future change?
In this case it's just a simple object which I have no intention of changing in the future.
>>and what's the difference in overhead really?
Say for instance I want to use the lprcSize LPRECT.
With a class I'd have:
Code:
//class definition/function implementations
class CTile
{
private:
LPRECT lprcSize;
public:
CTile();
~CTile();
void SetSize(LPRECT NewSize);
LPRECT GetSize();
};
CTile::CTile()
{
SetRectEmpty(lprcSize);
lprcSize=NULL;
}
CTile::~CTile()
{
SetRectEmpty(lprcSize);
lprcSize=NULL;
}
void CTile::SetSize(LPRECT NewSize)
{
CopyRect(lprcSize,NewSize);
}
LPRECT CTile::GetSize()
{
return(lprcSize);
}
//declaration
CTile ctile;
//initialization
RECT rcTemp;
SetRect(&rcTemp,0,0,32,32);
ctile.SetSize(&rcTemp);
//using return value
if(IntersectRect(&rcDst,ctile.GetSize(),&rcTestRect))
{
//do stuff
}
Using the struct I'd have:
Code:
//definition
struct Tile
{
LPRECT lprcSize;
};
//declaration
Tile tile;
//initialization
SetRect(tile.lprcSize,0,0,32,32);
//checking return value
if(IntersectRect(&rcDst,tile.lprcSize,&rcTestRect))
{
//do stuff
}
>>use the class just because i find it easier to read.
I don't see anything hard to read about the struct example.