Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++, "canceling a construction"

Name: Anonymous 2009-11-04 15:25

Hi /prog/

My is simple, but perhaps not so frequent.

How should I stop a construction of an object (c++)?

Basically I have a class with some data members which must fulfill some requirements. Say we initialize these data members upon construction, if the supplied values were erroneous then I guess I want to stop construction and throw an error. Is this the right idea? How do I "cancel the construction"?

Help much appreciated :)

Name: Anonymous 2009-11-04 23:45

>>15
WTF? I have an object representing an on-disk data structure which has methods for reading and manipulating it. Why the fuck would this not open a file? Why the fuck would the constructor not fail if it can't access the data structure it's supposed to represent?

Is my solution not fucking complicated and enterprise enough? Is that it? Do I need an ObjectFileProtocol and a FileSecurityPolicy and a FileAccessorFactory? No. The constructor opens the file and the destructor closes it. The methods manipulate the data. Simple, RAII, encapsulated, exception safe. How is this not object oriented?

Name: Anonymous 2009-11-04 23:54

>>15
Also, how the fuck is opening a file in a constructor a 'heisenbug'? It's a very obvious and explicitly defined point of failure; if the file doesn't exist, this constructor will throw. You need to catch this somewhere and display an error to the user.

We used to say heisenbugs are the kind of bugs that disappear when you try to debug them. I don't think that word means what you think it means.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List