> I didn't mean references specifically. I just meant the entire language.
> Nobody would try to claim that C++ is small or simple or free of
> surprises. For example,
>
> struct Side
> {
> Pattern & ThePattern;
> Side(Pattern p) : ThePattern(p) {}
> }
>
> Guess what? This segfaults when I run it. *You* probably see the problem
> immediately, but it took me 24 hours to figure out that there's a single
> missing character there...
Hence every compiler is able to emit a - more or less (depends on the
compiler you use) helpful - warning here.
So it is a good idea to compile always with a high warning level and you
should respect the emitted warnings.
>
> Today it's references. Last time it was
>
> catch (std::exception e)
> {
> std::cout << e.what();
> }
Even better: I wrote code like this:
if(error)
{
std::runtime_error("XY went wrong");
}
but no exception occured, because ... I forgot to _throw_ the exception. :-)
Lars R.
Post a reply to this message
|