Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Intermediate
Jul 16, 1999

Do Not Use Operator New in a Throw Statement

Dynamic allocation of an exception (as in this example) is not a good idea:

 
class Err{
public: 
  Err(const char * description);
};

void f()
{
  if (disaster)
    throw new Err("failed");  //exception object is dynamically allocated on the free store
  //
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap