Using operator new (or malloc() in C) to create objects on the heap is expensive in terms of performance (allocating heap memory usually involves a long negotiation with the OS), maintenance (dynamic allocation may fail; extra code to handle such exception is required) and safety (object may be deleted more than once or not deleted at all) as demonstrated in the following example:
void f() {string *p = new string(2000); //initial size of 2000 chars //...meddle with pif (condition) { cout<<
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.





















