Errata for Multi-Paradigm Programming using C++

  1. (p63) Last sentence in paragraph 4.2.11:
    cout << r.operator double();
    
    instead of
    cout << Rational::operator double(r);
    
  2. (p78) In code example (6 lines from bottom):
    is.putback(c)
    
    instead of
    cin.putback(c)
    
  3. (p96) In code example:
    const int MAX_SIZE(10);
    
    is better than
    int MAX_SIZE(10);
    
  4. (p98) 6th line from bottom: q + n = p instead of p + n = q.
  5. (p106) Replace
    Semantically, the delete and delete[] operators:
    by
    Semantically, a delete or delete[] expression:
    At the end of the third point, the following should be added:
    ... to the operating system (but this behaviour can be overriden by overloading the operator, see page 110).

    (Francis Glassborow, 2/2002).
  6. (p108) In definition of operator<<(ostream&, const String&):
     return os << s.data();
    
    instead of
     return os << data();
    
  7. (p112) In first paragraph: Pool::dealloc(void*) instead of Pool::dealloc(Rational*).
  8. (p115) First paragraph in Section 5.8.3. should refer to Chapter 7 instead of Chapter 6.
    (Joris Bleys, 12/4/2002).
  9. (p124) Member initialization of Array<T>::Array(unsigned int size):
    template <typename T>
    class Array {
      Array(unsigned int size =10): data_(new T[size]), size_(size) {}
    ..
    
    instead of (size_ is used before it is defined).
    template <typename T>
    class Array {
      Array(unsigned int size =10): data_(new T[size_]), size_(size) {}
    ..
    
  10. (p125) In Array<T>::operator=(const Array& a):
    if (this==&a) // self assignment
      return *this;
    
    instead of
    if (this==&a) // self assignment
      return;
    

    (Arnout Swinnen, 7/12/2001).
  11. (p135) Constructor of String should enforce invariant data_.get() != 0 (don't allow 0 pointers as argument to init()):
    class String { 
    // A simple string class, implemented using auto_ptr.
    public:
      String(const char* cstring=""): data_(init(cstring?cstring:"")) {}
    ..
    
    instead of
    class String { 
    // A simple string class, implemented using auto_ptr.
    public:
      String(const char* cstring=0): data_(init(cstring)) {}
    ..
    
  12. (p157) The Dictionary::hash() function should not be static:
    class Dictionary {
      ..
      unsigned int hash(const string& s) { return scramble(s)%size_; }
    };
    
    instead of
    class Dictionary {
      ..
      static unsigned int hash(const string& s) { return scramble(s)%size_; }
    };
    
  13. (p187) Text should refer to da variable, not to ad.
    (Joris Bleys, 12/4/2002).
  14. (p202) Use getline(is,class_name) instead of (is>>class_name) in the code for PersistentObject::read. This will properly read the newline character written after the class name by PersistentObject::write().
    (Davy Van Nieuwenborgh, 26/10/2001).
  15. (p211) Add underscore to fd in code (2nd line from the bottom):
     if (fd_ != -1) close(fd_);
    
    instead of
     if (fd != -1) close(fd_);
    

    (Mathieu Bram, 8/11/2001).
  16. (p212) Add underscore to fd in code:
     ~File() { if (fd_ != -1) close(fd_); }
    
    instead of
     ~File() { if (fd != -1) close(fd_); }
    

    (Mathieu Bram, 8/11/2001).
  17. (p247) Use
    static const string FORMAT_ERROR("not a number");
    
    instead of
    static const FORMAT_ERROR("not a number");
    
    in Figure 11.3.
    (Mathieu Bram, 8/11/2001).

Dirk Vermeir (dvermeir@vub.ac.be) [Last modified: Sat Feb 22 13:28:54 CET 2003 ]