Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > BOOK: Professional C++, 2nd Edition
|
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 May 15th, 2015, 08:01 PM
Registered User
 
Join Date: Apr 2015
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default In-class initialization of static variables

On page 181 is the following code from Spreadsheet.h:

static int sCounter = 0;

Using GCC Ver 4.9.2 I get the following error message:

Error: "Spreadsheet.h|34|error: ISO C++ forbids in-class initialization of non-const static member ‘Spreadsheet::sCounter’|"

This is the only code I've found in this book that doesn't compile on this compiler (set to conform to "C++ 11 ISO C++ language standards.") Anyone know why this is happening?

Thanks.
 
Old May 16th, 2015, 04:23 AM
Wrox Author
 
Join Date: Mar 2011
Posts: 49
Thanks: 0
Thanked 4 Times in 4 Posts
Default

That was a bug in the second edition and has already been fixed in the third edition of the book.
The Following User Says Thank You to Marc Gregoire For This Useful Post:
bangorme (May 16th, 2015)
 
Old May 16th, 2015, 07:32 AM
Registered User
 
Join Date: Apr 2015
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks for replying. Just as a suggestion, perhaps the proper code could be added to the errata page. I'm assuming the proper course is to use your non-C++ 11 coding instructions in the book.

Thanks again.
 
Old May 16th, 2015, 09:00 AM
Wrox Author
 
Join Date: Mar 2011
Posts: 49
Thanks: 0
Thanked 4 Times in 4 Posts
Default

I have started the errata procedure, so it should appear in the online errata in the coming days.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Static variables in Static Class JoinTTT BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 4 March 29th, 2009 05:08 PM
Using logging class as a static class punitw General .NET 0 August 14th, 2008 03:03 AM
Problem with static variables behaviour shujamughal ASP.NET 2.0 Professional 4 July 21st, 2007 01:56 AM
Declaring static variables in ASP lakshmi_annayappa ASP.NET 1.0 and 1.1 Basics 1 May 24th, 2007 06:49 AM
who destroy static variables(no instance of class) MikoMax J2EE 1 March 31st, 2004 08:01 AM





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