[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ? about C++



* Craig Dickson (crdic@yahoo.com) spake thusly:
> begin  Dimitri Maziuk  quotation:
> 
> > Does anyone know about a school that teaches people to use
> > vector<>, auto_ptr<>, basic_string and references?
> 
> I have no idea what they teach in school these days, but I should think
> they would have to teach references if they teach operator overloading.

Not according to the code I get to play with.

[ snip ]
> The standard auto_ptr<> is an abomination.
[ snip ]

Well, there's that... I'd argue that garbage collection is very
hard to get 100% right anyway, and there are other ways to detect
memory leaks...

Anyhow, my point was, name 4 problem areas in C.

1. No array bounds checking (Fix: use vector<> or equivalent)
2. Pointers (Fix: use references, iterators etc.).
3. Forgetting to free() malloc()'ed memory (Fix: use auto_ptr<>, 
   destructors etc.)
4. Using pointers to (hopefully array) (hopefully allocated) (hopefully
   null-terminated) of char as string data type (see also 1, 2, & 3)
   (Fix: use std::string)

We have a bunch of "C++" code written by CS students here, and I get to
support it. Guess which of the "fixes" above one finds in their code?

Dima (A: none of the above)
-- 
Tlaloc: What was Elrond's second name?
Gruber: Hubbard                           -- <ahbou=3C69EB63.A7C431F4@last.com>



Reply to: