Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 32,547 of 33,346    |
|    Edward Rosten to Seungbeom Kim    |
|    Re: Exception in Constructor    |
|    19 Sep 12 11:54:36    |
      From: firstname.dot.lastname@googlemail.com              On Tue, 18 Sep 2012 11:44:23 -0700, Seungbeom Kim wrote:              OK, It looks like I didn't state my intentions clearly...              > On 2012-09-18 06:21, Edward Rosten wrote:       >       > Why call the nothrow version, only to throw later?              I was trying to make the example applicable to a more general example       of resource allocation. Generally, resource allocating functions       (i.e. lots of stuff with a C interface) return NULL. The example was       meant to be representative of the general case, rather than the       specific case of memory, which is a bit simpler...              Perhaps using POSIX open/close would have been more illustrative.              > Again, this should be 'delete[] data;'.              Well, this lends weight to the original point :)              It's also why I don't generally write my own memory allocating       structures.              >> };       >       > Using a 'const' data member effectively prevents assignment, but the       > class still allows copy construction, which will lead to double       > delete. You should do something to prohibit copy construction, or       > write a copy constructor with a suitable semantics.              Oops yes. I was trying to string together a quick example. The idea       was to avoid writing an accessor function and prevent assignment. I       should have added a deleted copy constructor too.                     -Ed                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca