overloading operator new

Kevin Yohe kevin@ssc-nh.com
Fri May 18 17:51:00 GMT 2007


Hello.  I have implemented my own storage manager and I am trying to
overload the 'operator new' for an allocated block class and I get the
following errors.

powerpc-750-elf-gcc -c -r -gdwarf-2 -fno-exceptions -fno-weak -fno-check-new
cCommandDispatcher.cpp -o cCommandDispatcher.o
In file included from cCommandDispatcher.cpp:26:

cAllocatedBlock.h:69: error: declaration of 'operator new' as non-function
cAllocatedBlock.h:69: error: expected ';' before '(' token

from cAllocatedBlock.h ...

class cAllocatedBlock : public cQueueBlock
{	// cAllocatedBlock
public:
		...

            // Public Operators //

            void * operator new(size_t size);
            void operator delete(void * block);
		...

};          // cAllocatedBlock

I am using gcc-4.1.0 configured for a powerpc.  I am doing most of my
development on a pc using visual studio 2005, where this code compiles
without errors.  I find the error message itself perplexing.  What does it
mean by non-function?  What am I doing wrong?

Regards,
Kevin




More information about the Gcc-help mailing list