Wiley.com
Print this page Share

Professional C++, 2nd Edition

ISBN: 978-0-470-93244-5
Paperback
1104 pages
October 2011
Professional C++, 2nd Edition (0470932449) cover image
This title is out-of-print and not currently available for purchase from this site.

Do you think you've discovered an error in this book? Please check the list of errata below to see if we've already addressed the error. If not, please submit the error via our Errata Form. We will attempt to verify your error; if you're right, we will post a correction below.

ChapterPageDetailsDatePrint Run
22 Error in Code
Reads:
#include <iostream>
#include <array>
using namespace std;
int main()
{
                array<int, 3> arr = {9, 8, 7};
                cout << "Array size = " << arr.size() << endl;
                for (auto i : arr)
                                cout << i << endl;
                                cout << *iter << endl;

                return 0;
}

Should be:
#include <iostream>
#include <array>
using namespace std;
int main()
{
                array<int, 3> arr = {9, 8, 7};
                cout << "Array size = " << arr.size() << endl;
                for (auto i : arr)
                                cout << i << endl;

                return 0;
}


10/26/2011
28 Error in Code
Currently reads:
char* pointerString = "Hello, World";

Should read:
const char* pointerString = "Hello, World";
06/04/2012
7 181 Error in Code
Currently Reads:
static int sCounter = 0;
Should Read:
static int sCounter;

Followed by the following paragraph:
Currently Reads:
In addition to listing static class members in the class defi nition, you will have to allocate space for them in a source fi le, usually the source fi le in which you place your class method defi nitions.You can initialize them at the same time, but note that unlike normal variables and data members, they are initialized to 0 by default. static pointers are initialized to nullptr. Here is the code to allocate space for and initialize the sCounter member in pre-C++11:

Should Read:
In addition to listing static class members in the class definition, you will have to allocate space for them in a source file, usually the source file in which you place your class method definitions. You can initialize them at the same time, but note that unlike normal variables and data members, they are initialized to 0 by default. static pointers are initialized to nullptr. Here is the code to allocate space for and initialize the sCounter member:
Currently Reads:
int Spreadsheet::sCounter = 0;
Should Read:
int Spreadsheet::sCounter;

This code appears outside of any function or method bodies. It's almost like declaring a global variable, except that the Spreadsheet:: scope resolution specifies that it's part of the Spreadsheet class.
6 June 2015
232 Error in Text
The sentence:
?No code needs to be written in the .cpp file, and any attempt to write code will cause a compiler error.?

Should become:
?No code needs to be written in the .cpp file.?
08/17/2012
xiii, 258 Error in Text
Currently reads:
Copy Constructors and the Equals Operator in Subclasses

Should read:
Copy Constructors and the Assignment Operator in Subclasses
06/04/2012
390 Error in Text
The first sentence on this page says:
"The standard containers that provide iterators all furnish either random access or bidirectional iterators."

This is untrue and should be deleted.
06/04/2012
414 Error in Text
Sentence in second paragraph currently reads:
"A list supports begin(), returning an iterator referring to the first element in the list, and end(), returning an iterator referring to the last element in the list."

Sentence should read:
"A list supports begin(), returning an iterator referring to the first element in the list, and end(), returning an iterator referring to one past the last element in the list."
06/04/2012
468 Error in Code
Code currently reads:
int cnt = count_if(vec.cbegin(),vec.cend(),
[=, &cntLambdaCalled](int i){++cntLambdaCalled; return i>value;});


Code should read:
int cnt = count_if(vec.cbegin(),vec.cend(),
                     [=, &cntLambdaCalled](int i)->bool{++cntLambdaCalled; return i>value;});
06/04/2012
487 Error in Text
The description of lexicographical_compare() currently reads:
lexicographical_compare() deals with the situation where the two ranges may contain different numbers of elements. It returns true if all the elements in the first range are less than their corresponding elements in the second range, or, if the first range has fewer elements than the second and all elements in the first range are less than their corresponding initial subsequence in the second set.

This should read:
"... It returns true if the first unequal element in the first range is less than its corresponding element in the second range, or, if the first range has fewer elements than the second and all elements in the first range are equal to their corresponding initial subsequence in the second set."
06/04/2012
596 Error in Text
Currently reads:
"This regular expression searches for spaces, newlines, form feeds, and back slashes."

Should read:
"... newlines, carriage returns, and back slashes."
06/04/2012
596 Error in Text
Currently reads:
"Every reversible container in the STL, which happens to be every container that's part of the standard, ..."

Should read:
"Every reversible container in the STL, which happens to be every container that's part of the standard, ...except forward_list and the unordered associative containers".
06/04/2012
685 Error in Code
Please replace current code Gameboard.H with:
class GameBoard
{
public:
       // The general-purpose GameBoard allows the user to specify its dimensions
       GameBoard(size_t inWidth = kDefaultWidth, size_t inHeight = kDefaultHeight);
       GameBoard(const GameBoard& src); // copy constructor
       virtual ~GameBoard();
       GameBoard& operator=(const GameBoard& rhs); // assignment operator

       void setPieceAt(size_t x, size_t y, const GamePiece* inPiece);
       GamePiece* getPieceAt(size_t x, size_t y);
       const GamePiece* getPieceAt(size_t x, size_t y) const;

       size_t getHeight() const { return mHeight; }
       size_t getWidth() const { return mWidth; }
       static const size_t kDefaultWidth = 10;
       static const size_t kDefaultHeight = 10;

protected:
       void copyFrom(const GameBoard& src);
       void initializeCells();
       void cleanupCells();
       // objects dynamically allocate space for the game pieces.
       GamePiece*** mCells;
       size_t mWidth, mHeight;
};
06/04/2012
685 Error in Text
The last paragraph currently reading:
...?getPieceAt() returns a reference to the piece?? and ends with ??before using the returned reference.?

This should be deleted.
06/04/2012
686 Error in Text
The note at the top of the page currently reads:
"This implementation of the class provides two versions of getPieceAt(), one of which returns a reference and one of which returns a const reference."

This should should be deleted.
06/04/2012
686-687 Error in Code
The code on pages 686-687 (Gameboard.cpp) should be deleted and replaced with the following:

GameBoard::GameBoard(size_t inWidth, size_t inHeight) :
  mWidth(inWidth), mHeight(inHeight)
{
  initializeCells();
}
GameBoard::GameBoard(const GameBoard& src)
{
  copyFrom(src);
}
GameBoard::~GameBoard()
{
  // free the old memory
  cleanupCells();
}
void GameBoard::copyFrom(const GameBoard& src)
{
  mWidth = src.mWidth;
  mHeight = src.mHeight;

  initializeCells();

  for (size_t i = 0; i < mWidth; i++) {
    for (size_t j = 0; j < mHeight; j++) {
      if (src.mCells[i][j])
        mCells[i][j] = src.mCells[i][j]->Clone();
    }
  }
}
void GameBoard::initializeCells()
{
  mCells = new GamePiece** [mWidth];
  for (size_t i = 0; i < mWidth; i++) {
    mCells[i] = new GamePiece*[mHeight];
    for (size_t j = 0; j < mHeight; j++) {
      mCells[i][j] = nullptr;
    }
  }
}
void GameBoard::cleanupCells()
{
  for (size_t i = 0; i < mWidth; i++) {
    for (size_t j = 0; j < mHeight; j++) {
      delete mCells[i][j];
    }
    delete [] mCells[i];
  }
  delete [] mCells;
  mCells = nullptr;
}
GameBoard& GameBoard::operator=(const GameBoard& rhs)
{
  // check for self-assignment
  if (this == &rhs) {
    return *this;
  }
  // free the old memory
  cleanupCells();
  // copy the new memory
  copyFrom(rhs);
  return *this;
}
void GameBoard::setPieceAt(size_t x, size_t y, const GamePiece* inElem)
{
  if (inElem)
    mCells[x][y] = inElem->Clone();
}
GamePiece* GameBoard::getPieceAt(size_t x, size_t y)
{
  return mCells[x][y];
}
const GamePiece* GameBoard::getPieceAt(size_t x, size_t y) const
{
  return mCells[x][y];
}



06/04/2012
687 Error in Code
Currently reads:
GameBoard chessBoard(8, 8);
ChessPiece pawn;
chessBoard.setPieceAt(0, 0, pawn);


Should read:
GameBoard chessBoard(8, 8);
ChessPiece pawn;
chessBoard.setPieceAt(0, 0, &pawn);

06/04/2012
689 Error in Text
Text currently reads:
?mCells is now a T** instead of a GamePiece** because??

Should read:
?mCells is now a T** instead of a GamePiece*** because??
06/04/2012
803-804 Error in Text
Currently reads: 10.000 and 100.000

Should read: 10,000 and 100,000.
06/10/2013
1053 Error in text
Currently reads:
- - decrement operator, 11

Should read:
-- decrement operator, 11 (space between symbols)
04/25/2012
22 Text Correction: Error in Code
there is no code example for pool threads in Chapter 22 of Professional C++, 2nd Edition. Is there intended or is code meant to be available?
05/01/15
Back to Top