Re: Class objects work like built-in types, but is it worth it?
Fat fingers! :) The post went out incomplete.
On Oct 23, 10:44 am, acehr...@gmail.com wrote:
On Oct 23, 10:38 am, tonytech08 <tonytec...@gmail.com> wrote:
The question is about the value of class objects
behaving like built-in types: How valuable/beneficial/desireable is
that? Or more specifically, was it worth introducing all that
ancillary machinery (exceptions) to get that feature?
I am not convinced that exceptions were introduced so that we could
say
MyType m;
I read the Design and Evolution of C++ a long time ago but don't
remember registering anything like that. Perhaps all objects could be
pointers and NULL could be returned?
MyType * m = new MyType();
[I was going to add...]
Then we would have to check every object creation:
if (!m) // cannot continue
We wouldn't be able to chain function calls:
calculate(make_first(), make_second());
It should be done noisily:
FirstType * f = make_first();
if (!f) goto bail;
SecondType * s = make_second();
if (!s) goto bail;
calculate(f, s);
That would be C-like in a bad way. :)
Can you think of a better way without exceptions from constructors?
Ali