Possible Duplicate:
C++ return a “NULL” object if search result not found
I'm trying to return NULL on a certain condition but it won't let me, why not and how can i make it return a null value or 0?
struct Entity
{
USHORT X;
USHORT Y;
UINT Serial;
USHORT SpriteID;
EntityType Type;
Direction FacingDirection;
};
the function is:
Entity& GetEntityAt(int index)
{
if (!GameObjects.empty())
{
lock_guard<mutex> lock(PadLock);
Entity& result = GameObjects[index];
return result;
}
return NULL; // <- this won't compile
}