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-11 9:26

>>75
Stack traces are platform specific to begin with
...because the C++ standard does not support them.

You've maybe heard of the C++ standards committee and their the `C++98 standard'
...which does not include stack traces.

Why the fuck is this so hard to understand? Languages like Java or Python include stack traces, and these are available in a portable way inside the application itself. C++ could have done this. It could have been a requirement of the standard.


Why is this so hard to understand?


If it's convoluted then you're doing it wrong. For example you don't mix user-defined and STL exceptions. You choose either and stick with it throughout your application/system/library.
Wow, this is some terrible exceptions advice. You are *always* supposed to subclass std::exception to create your own exceptions. You can't get away from built-in exceptions without getting rid of the entire STL (and replacing new so that it doesn't throw).

Exceptions provide a single, standardised error handling facility.
You mean, if you choose either STL or custom exceptions and hope every library you use does the same? Isn't this the very opposite of what you just said?

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