I am trying to complie and test a memory manager but 1 of my overloaded operators isn't being seen and I'm not too sure why:
int main()
{
.
.
Stuff
.
.
// This allocation should automatically go into their hierarchical heaps
GameEntity * pEntity = new GameEntity; /* works ok */
GameEntity * pCamera = new GameCamera; /* works ok */
GameEntity * pCamera2 = new GameCamera; /* works ok */
const int numActors = 20;
GameEntity * pActor[numActors];
for (int i=0; i<numActors; ++i)
pActor = new GameActor; /* works ok */
// This is a custom allocation in a specific heap
Heap * pHeap = HeapFactory::CreateHeap("CustomHeap");
int * pBuffer = new (pHeap) int[512]; /* This line is causing problem */
.
.
More stuff
.
.
return 0;
}
overloaded operator stuff:
Header File
#include "HeapFactory.h"
#include <cstddef>
void * operator new (size_t size, Heap* pHeap); /* Not being seen */
void * operator new (size_t size); /* this is ok though */
void operator delete (void * pMem, size_t size);
.
.
More stuff
.
.
#endif
Source file:
#include "MemoryMgr.h"
#include "Heap.h"
#include "HeapFactory.h"
#include <assert.h>
void* operator new (size_t size, Heap* pHeap) /* Not being seen */
{
assert(pHeap != NULL);
return pHeap->Allocate(size);
}
void* operator new (size_t size) /* Is being seen */
{
return operator new (size, HeapFactory::GetDefaultHeap() );
}
void operator delete (void * pMem)
{
if (pMem != NULL)
Heap::Deallocate(pMem);
}
complier error:
main.cpp: In function `int main()':
main.cpp:27: error: no matching function for call to `operator new [](unsigned int, Heap*&)'
<internal>:0: note: candidates are: void* operator new [](unsigned int)
The code is actually from a book called "C++ for Games Programmers" and was in a visual C++ project. I'm using Dev-c++, am not too sure if that would be an issue as I created a new project and added the source files.
Can anyone see what the problem is?