Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2005
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2005 by Ivor Horton; ISBN: 9780764571978
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 27th, 2007, 04:53 PM
Authorized User
Points: 174, Level: 3
Points: 174, Level: 3 Points: 174, Level: 3 Points: 174, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default beginner C++ question p62

in discussing enum's, the example for a bool enum is given

enum State : bool { On = true, Off};

I get this error when I include this line in my main() function:
Error 1 error C3168: 'bool' : illegal underlying type for enum c:\documents and settings\<user snipped>\my documents\visual studio 2005\projects\c++\ex2_01a\ex2_01a\ex2_01a.cpp 20

Here's my MFC Console .cpp file:

#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{

enum State : bool {On=true, Off} myState;
myState = On;

//I try the std::cout line below, but it's not in the book
//but my compile error is on the "enum State : bool" line

std::cout << "state = " << (int)myState << std::endl;

return 0;
}



Sincerely,
Brian
__________________
Sincerely,
Brian
  #2 (permalink)  
Old January 30th, 2007, 04:24 PM
Authorized User
 
Join Date: May 2006
Location: Iver, Bucks., United Kingdom.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

See your problem -i.e. I can duplicate it, but have not found a solution. I suggest emailing the author -and please post answer.

  #3 (permalink)  
Old February 1st, 2007, 02:53 PM
Authorized User
Points: 174, Level: 3
Points: 174, Level: 3 Points: 174, Level: 3 Points: 174, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know how to reach the author. Does Ivor state in the book that he is open to comments / questions?




Sincerely,
Brian
  #4 (permalink)  
Old February 2nd, 2007, 01:13 AM
Authorized User
 
Join Date: May 2006
Location: Iver, Bucks., United Kingdom.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Go to http://www.wrox.com/WileyCDA/WroxTit...ew_errata.html

and fill in the form at
http://wrox.custhelp.com/cgi-bin/wro...nduser/ask.php

Btw the Errata page, linked to above, now lists some corrections.

Edit:
You may find the following Visual Studio forum useful, especially for the above problem.
http://forums.microsoft.com/msdn/sho...id=29&siteid=1
  #5 (permalink)  
Old February 7th, 2007, 03:23 PM
Authorized User
Points: 174, Level: 3
Points: 174, Level: 3 Points: 174, Level: 3 Points: 174, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I contacted Wiley/Wrox about this, and they got this feedback from the auther, Ivor Horton.

Per the author:

>>The example on P. 62 is not correct. The enum with type bool enumerators should be:

enum State : bool {On=true, Off=false};

The original fragment used to compile but the compiler was ultimately modified to enforce the rule that enumerators in an enum of type bool must all be explicitly initialized. C++/CLI enums of other explicit types do not need to be initialized explicitly, although they can be.

Note that the section "Specifying the Type for Enumeration Constants" is misplaced and should be a subsection of the "C++/CLI Programming" section as it is specific to C++/CLI.Regular C++ only supports enums with an implicit integral type for the enumerators.<<


Sincerely,
Brian
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt beginner question cfflexguy XSLT 4 October 16th, 2007 09:11 AM
Beginner Question dkr72 Excel VBA 1 January 18th, 2005 08:37 AM
Beginner question on getting only certain elements EstherMStrom XSLT 5 December 10th, 2004 03:38 PM
beginner question saudyonline General .NET 2 September 21st, 2004 01:56 AM
Stupid Question from a BEGINNER Shappy Access VBA 1 May 11th, 2004 03:32 AM



All times are GMT -4. The time now is 02:15 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.