Re: ? about C++
* Anthony DeRobertis (asd@suespammers.org) spake thusly:
>
> On Thursday, March 7, 2002, at 03:57 PM, Dimitri Maziuk wrote:
> >Anyhow, my point was, name 4 problem areas in C.
> >
>
> You're lucky with 'none of the above'. It could be...
Luck has nothing to do with it
> >1. No array bounds checking (Fix: use vector<> or equivalent)
>
> Real-world idiot fix: My name is 7 characters; give it twenty,
> we'll never need more than that! Then use that twenty inline in
> the code, as well as simplifying the expressions a little so we
> get the related constants 21 (w/ null), 19 (can't count,
> paranoid), 8, 9, 10 (unicode), and infinity (core dump).
>
> >2. Pointers (Fix: use references, iterators etc.).
>
> Real-world idiot fix: Pass everything by value. Who needs
> pointers, references, etc.? Use indices with magic constants as
> the bounds (see above) to iterate arrays.
>
> BTW: I disagree _strongly_ that pointers are a misfeature of C.
> They are a very useful tool. However, misuse of pointers
> is a misfeature of some programmers.
Real-world troubleshooting technique: put ulimit on stack size.
If program segfaults on int main( int argc, char **argv ),
------------------------- segfault here -----------^^^^
it has both of the above.
[ snip ]
Yeah. BTDT, got more t-shirts than I'll ever need.
Dima
--
The wombat is a mixture of chalk and clay used for respiration. -- MegaHal
Reply to: