JamesBrown,
The problem lies in the method you used to open a new project. At this stage of the book, there are two types of programs Win32 Console programs and CLR C++/CLI programs. The preprocessor directive
#include "StdAfx.h" is used in CLR C++/CLI programs. The Win32 console programs do not use this preprocessor directive.The code as presented in the book is for a Win32 Console Project.
When going through the book, there are a few ways to tell which type of project to open:
- Up to this point in the book, all example programs at the beginning of the chapter are Win32 Console programs. When you come to a bold topic heading which says "C++/CLI PROGRAMMING", you are entering that type of examples.
- Look in the highlighted bar nest to the TRY IT OUT bar or the text under the highlighted bat to see if it mentions a CLR program. If so, that example and the ones following are going to be C++/CLI programs.
- As time progresses you will recognize the difference by repetition.
When I began the book, I printed out all the code for the different types of projects and made notes on them for reference. You may find it helpful to do the same.
To make your code compile and run go back to Chapter 1 and read the procedure for
Creating a Project for a Win32 Console Application in the TRY IT OUT FOUND under the
Defining a Project topic heading. This is on page 14 of my book. It may be on a different page if you have a different printing of the book. Then type the code and build it again. Let me know how that works for you.
drpepper