Re: C# vs. C++ (was Re: UNICODE conversion)
"David Ching" <dc@remove-this.dcsoft.com> ha scritto nel messaggio
news:_Z1Cj.425$p24.55@nlpi061.nbdc.sbc.com...
I like C#, but I miss: destructors
As you know, C# has Dispose, which is similar to destructors (but not the
same).
, default parameters,
They use method overloads instead of default parameters.
However, I also miss default params (they allow us to write less overloaded
method signatures).
I had pretty much ignored exceptions in C++ until I learned .NET because
they are used everywhere there. I really got used to C#
try-catch-finally. I'm kind of blown away that in C++ there is no
'finally' (at least I don't think there is).
David: I'm not the right person to answer these kind of things for C++ :)
but I think that there is no finally in C++ because C++ has RAII (or better,
C++ code should be written in an exception safe way using RAII).
However, I must confess that I'm not very expert of exception safety... I
use std::vector instead of new[], and try to use smart pointers, and I hope
it is OK to build exception-safe code. But if writing exception-safe code
should require too many programmer's "brain clock-cycles" (like doing
special things in copy constructors, etc.) and so programmer's focus shifts
from the real problem to solve to details like exception safety or others,
well I prefer focusing on the problem and not much on the details.
(At the end of the day, I think that when an application is terminated by an
unhandled exception, Windows does proper cleanup to application resources
like memory or allocated handles...)
Moreover, I don't understand why people call that thing RAII and not RRID
(Resource Release Is Destruction), which I think that capture better the
meaning of this technique...
G