M
Min
class Foo
{
public:
char name[20];
Foo() { /*** Do Something ***/ }
Foo( char* str) { /*** Do Something ***/ }
static void * operator new(unsigned int size)
{
//*********************
// Code from Effective C++
//*********************
void* memory = null;
if ( size == 0 ) { size = 1; }
try
{
memory = :
perator new(size);
}
catch (std::bad_alloc&)
{
throw;
}
return memory;
}
};
void main()
{
Foo * ptrFoo1 = new Foo(); // Uses Overloaded New
Foo * ptrFoo2 = new Foo("What's up"); // Uses Overloaded New
Foo *ptrFoo3 = new Foo[10]; // Uses DEFAULT New.
}
//*******************************************
Using a debugger (VC++ 6.0 if it is important), I find that ptrFoo3 does not
use the overloaded new operator. Anybody knows why ? or if I am missing
something. Or is it the vendor ? or language ?
{
public:
char name[20];
Foo() { /*** Do Something ***/ }
Foo( char* str) { /*** Do Something ***/ }
static void * operator new(unsigned int size)
{
//*********************
// Code from Effective C++
//*********************
void* memory = null;
if ( size == 0 ) { size = 1; }
try
{
memory = :
}
catch (std::bad_alloc&)
{
throw;
}
return memory;
}
};
void main()
{
Foo * ptrFoo1 = new Foo(); // Uses Overloaded New
Foo * ptrFoo2 = new Foo("What's up"); // Uses Overloaded New
Foo *ptrFoo3 = new Foo[10]; // Uses DEFAULT New.
}
//*******************************************
Using a debugger (VC++ 6.0 if it is important), I find that ptrFoo3 does not
use the overloaded new operator. Anybody knows why ? or if I am missing
something. Or is it the vendor ? or language ?