Dr. Dobb's Journal March 1997
class Foo
{
public:
Foo();
~Foo();
}
// allocation
Foo* pBar = (Foo *)malloc(10*sizeof(Foo));
// construction
for (i = 0; i< 10; i++)
(pBar + i)->Foo::Foo();
// reallocation
pBar = (Foo *)realloc(pBar, 11*sizeof(Foo));
// construction of additional element
(pBar + 10)->Foo::Foo();
// destruction and deallocation
for (i = 0; i< 11; i++)
(pBar + i)->Foo::~Foo();
free(pBar);