Wrox Programmer Forums
BOOK: Professional C++, 2nd Edition
This is the forum to discuss the Wrox book Professional C++, 2nd Edition by Marc Gregoire, Nicholas A. Solter, Scott J. Kleper ; ISBN: 978-1-1181-6995-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C++, 2nd Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 24th, 2013, 03:34 PM
Registered User
Join Date: Jan 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Errata 685

In errata, you wrote
Please replace current code Gameboard.H with:

class GameBoard
// 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;

But I didn't find any explanations for why you have changed the code. What was wrong with the previous approach?
Old January 27th, 2013, 09:55 AM
Wrox Author
Join Date: Mar 2011
Posts: 49
Thanks: 0
Thanked 4 Times in 4 Posts

In the original code, the ChessPiece was copied to a GamePiece. The information that it's really a ChessPiece was not stored in the GameBoard. Object slicing was happening: only the GamePiece part of the ChessPiece was copied to the GameBoard. To make it work correctly, GameBoard should store GamePiece* instead of GamePiece. That's what the errata is doing now.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Errata? DrGaribaldi BOOK: Professional Android 2 Application Development 2 April 19th, 2011 11:39 AM
Where's the Errata? bobinorlando BOOK: Professional ASP.NET 3.5 SP1 Edition: In C# and VB 2 July 6th, 2010 10:17 AM
Errata vidyar_rajan Beginning PHP 0 August 31st, 2006 05:37 AM
Errata DaveSussman BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 November 6th, 2005 07:35 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.