Original Post
...returning a VOID* ... what does it do and how can i use it for my advantage?
quote:
Original post by Ready4Dis
void *AllocateMem(unsigned long Size)
{
void *MemToAllocate = new unsigned char[Size];
return MemToAllocate;
}
void Delete(void *Memory)
{
delete Memory;
}
malloc and free for void* allocation and deallocation.new unsigned char[Size], but you need to cast your void* pointer into an unsigned char* before deletion (and don't forget to delete it as an array):
void Delete(void *Memory)
{
delete [] reinterpret_cast<unsigned char*>(Memory);
}
// This is in my CObject.h file (base)
virtual VOID* GetObject()
{
return 0;
}
// This is in CTerrain.h file, (derives from CObject)
VOID* GetObject()
{
return this;
}
VOID* GetObject( int index )
{
return m_vObjects[index];
}
engine->GetObject( index )->SetCamerePos( camera->Pos );
CObject* GetObject( int index ) {
return m_vObjects[index];
}
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more