Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucsd!hub!ucsbcsl!frew From: frew@hub.ucsb.edu (James Frew) Newsgroups: comp.lang.c++ Subject: disappointed with Pohl's C++ book Message-ID: <2293@hub.UUCP> Date: 1 Sep 89 04:12:41 GMT Sender: frew@hub.UUCP Reply-To: frew@hub.ucsb.edu (James Frew) Organization: University of California, Santa Barbara Lines: 93 I'm 1/3 of the way through "C++ for C Programmers", by Ira Pohl, and I'm not going to finish it. Herewith a summary of the problems I've encountered so far: p. what -- ---- 10 The example contains an expression of the form "int = int * double." This causes a warning message from CC (ATT 2.0). The warning message is not mentioned in the text. This problem occurs in several subsequent examples. 16 CC gives a "used but not set" for class instances accessed only via their members. The warning is not mentioned in the text. 16 The output given for the example program is obviously incorrect. 17 The use of the same name for a member function and a global function is given as an example of "overloading". Is this true? I sure can't find this in bs's book, and it's not analogous to structures, whose members have their own namespace. 35 Ever since reading Harbison & Steele, I've been conscious of the important distinction between declaration and definition. That distinction is muddied here in the section named "Declarations", and elsewhere in the text. 37 random() is NOT a "standard library function", it's a BSD-ism. 48-49 an example is given of a program printing out uninitialized "new" storage. The comment in the "dissection" is "The programmer is responsible for properly initializing such objects". Why not just leave it out of the example altogther? 51 An example of anonymous unions contains the following code: union { int i; char c[4]; }; main() { i = 65; cout << form("%c", c[3]) << "\n"; } and it is asserted that the output is the letter "A". Obviously not tested on a VAX... for that matter, obviously not tested at all, since CC won't compile it unless the union is explicitly static (g++ 1.35.0 won't compile it at all...) 70 A very confusing reference to the fact that structure member functions share the same name space as structure member variables. 71 A code fragment contains: char stack::pop(int n) { while (n--) top--; ... } Is there some reason why the loop isn't just "top -= n" ? 71-72 An example contains a both a structure and a member named "s". The subsequent text refers to "the variable s": it's not clear which one. By this point, I found myself spending more time looking for mistakes than trying to understand C++. I am especially disappointed in the poor quality of the examples, since I believe the best way learn a new programming language is to read real programs (and, of course, start writing your own). It takes special care to construct useful examples out of a tutorial subset of a language, but it can be done -- witness both editions of "The C Answer Book" by Tondo and Gimpel. This care simply wasn't taken in "C++ for C Programmers", and as far as I'm concerned, that torpedos the whole book. Remember, the intended audience was people who already knew C, and therefore shouldn't be afraid of reading non-trivial code. Sorry to flame a book I'm not going to finish -- any counter-opinions? I'm still looking for a good intro to C++ for someone who already knows C. Would anyone out there who's read Lippman's or Dewhurst's books care to comment? #-----------------+-----------------------+----------------------------- # James Frew | frew@crseo.ucsb.edu | Computer Systems Lab., UCSB # +1 805 961 8413 | frew@ucsbuxa (BITNET) | Santa Barbara, CA 93106, USA