It's called "placement new", and it should be used only in very special cases.
Originally Posted by new_ink2001
int main( void )
using namespace std;
string* str = static_cast< string* >( malloc( sizeof( string ) ) );
Manually invoke the constructor.
new ( str ) string( "Hello World!" );
cout << *str << endl;
We can't use 'delete' because it may not be compatible with the result of our
'malloc' call, so we have to invoke the destructor and 'free' the memory manually.
free( str );