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++ 2010
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2010 by Ivor Horton; ISBN: 9780470500880
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2010 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 Search this Thread Display Modes
  #1 (permalink)  
Old June 4th, 2012, 06:55 AM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Visual C++ 2010

I am fairly familiar with "C" but am trying to expand into "C++" using Ivor Horton's book "Visual C++ 1010. I have a problem with compiling the programme on page 124. (Ex3_01) I had this problem from time to time in chapter 2 but decided to bypass it for the moment. However the problem on the above page is now becoming a major obstacle.

The error message that I get is< "Fatal error c010. unexpected end of file while looking for precompiled header. Did you forget to include "stdafx.h" in your source code.> I have tried both with this inclusion and without but it makes no difference.

I am using Windows XP and configuration C++/CLI.

Any suggestions please?
  #2 (permalink)  
Old June 5th, 2012, 08:11 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Cliffhassall,

three questions:

Is the error C1010? You posted c010.

Are you using the proper technique for starting a new project as described in Chapter 1?

Are you pasting code from a download, or manually typing the code?

drpepper
  #3 (permalink)  
Old June 6th, 2012, 07:53 AM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ivor Horton's book "Beginning Visual C== 2010

drpepper

Thanks for the reply

Yes I did mean error message C1010---Sorry

As far as I know I did use the correct start up proceedure as described in chapter 1. Always room for misinterpretation of course.

I typed in the code myself. Are the error messages acurate? I don't understand how the message can say that I should have included stdAfx. if Ivor doesn't think this is necessary I am sure it can't be.

I do worry about compiler setup. Is there any adjusment here which is a possible cause?


Regards

Cliff
  #4 (permalink)  
Old June 6th, 2012, 12:01 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Cliffhassall,

I will start by saying that you are a little ahead of me because you have a familiarity with C. My only background is an intro to programming course which included only about 6 weeks of C. However, I learned quite a bit about the Visual C++ error codes, not because of error problems, but because I am very curious by nature.

I am beginning the Exercises in Chapter 2; so I am going to ask you to refer to the Chapter 2 code where you experienced problems. That way I can be sure that we are on the same page if you have specific questions or you include code for any solutions. To help both of us I am going to break this post down into sections, each of which will have a header (or title line) in blue text. Please refer to the header when commenting or asking questions. That will go a long way toward creating effective communication.

Keep me informed regarding your progress, questions, or problems. If you run into a problem along the way, stop and post back with details.

Are you ready? ... Then let's go.

examine your code
This sounds way too simple, but simple errors in syntax or the order of statements is something I have found to be very common. Of particular nuisance is the quite human trait of missing obvious stuff when you are looking at it for the second, twenty first, or whatever time. Now that you have been away from the Chapter 2 exercises for a while, you may find something you have missed earlier. Pick one of the Chapter 2 exercises which gives you the compiler error. Tell me which one (Ex*_**). Use careful line-by-line comparison with the code in the book. Correct any errors you find.

If you find errors, correct them and try to compile again. If you still get the same compiler error or found no errors, continue to the next header.

check the help file entry on your compiler error
The help files for errors can be quite helpful, but they are hard to find. Here is where to find not only the error you have encountered, but all compiler and linking errors. The path is hard to find if you don't know where to look. You might want to paste this path into a Notepad document until you can find it without using a guide. Here is how to find your error:
1) Click Help on the menu bar.
2) Choose view help.
3) Expand the listed options (if they are not already expanded) by clicking the arrows. This is very similar to expanding folder views when looking for a folder or file in Windows Explorer. Here is the path: visual studio 2010 > visual studio > visual studios languages > visual c++ > c/c++ building reference > c/c++ build errors
4) Here you see a listing of categories for errors. Expand the error category you are looking for. In this case it is compiler fatal errors C999 through C1999.
5) In the right pane find your error number. Click on it.
6) Read the information carefully, and make any changes that look like they address your problem.

If you make any changes, try to build the solution again. If you still have not resolved your problem, continue on to the next header.

start a new project manually
Don't use the short cut keys. Use the menu bar and drop down menus to access the Wizards. Use the directions in the book for the type of project you are creating. It is quite possible that you may have configured your project incorrectly if you worked from memory without referring to the book. This is even more likely if you previously used a different compiler.

Either paste your code, or retype it once you have a new project started. Build the project, using the menu bar and drop down menus. If it compiles without errors, start the program without debug from the menu bar. The program should compile. If you have any problems or questions, give me a detailed explanation of the steps you have taken and the question or problem you encounter. That is the only way I can pinpoint possible solutions.

NOTE:
If you make it a practice to use the menu bar and manually create new projects, you will have a better understanding of the IDE and compiler. This can go a long way toward finding and correcting problems that are not actual coding problems.

Post back with your results.

drpepper
  #5 (permalink)  
Old June 7th, 2012, 01:53 AM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

second post since your last reply -- Please read other post also.

I have scanned ahead several chapters. There seems to be a pattern throughout the book. The examples which appear early in the chapter use native C++. Each chapter indicates when to begin using C++/CLI programs. Native C++ and C++/CLI are not identical when it comes to coding or creating a new project.

There is a reason for me bringing this up. I have been tutoring for well over forty years and learned a few things about the learning process. Effective learning is a process of starting with simple concepts and building upon them incrementally. The structure of this book uses that principle for more than one reason. The first and most obvious is to incrementally build on concepts. One of the other reasons is that you may not always be using the Visual C++ compiler. Understanding the concepts of native C++ is important for this reason.

I believe that you will find your learning experience more rewarding if you use native C++ and C++/CLI as the book directs. Personally I intend to create many of the solutions in both native C++ and C++/CLI to explore the differences. This is just the way I choose to learn.

now, with that said:
Your first post in this thread included Ex3_01 as one of the solutions where you have a problem. This example is intended to be written in native C++ where stdafx.h is not used. This does not directly address the problem you wish to resolve. Use the info in my previous post to try to resolve your fatal compiler error.

I am confident that I can guide you to a resolution. It may take several steps for me to form a picture based upon your replies containing observations and questions. If you have enough patience to walk through this with me step-wise, we may both learn something in the process.

Please take this post as encouragement and explanation. I do not intend for you to think that I am lecturing you.

drpepper
  #6 (permalink)  
Old June 9th, 2012, 03:49 AM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Visual C++ Ivor Horton

dear drpepper

Thanks for your reply.
Perhaps, as we are both beginners with IH's book we could take one chapter at a time.

chapter 3

EX3_01.cpp (p124)

The library declaration is <iostream> not "stdafx". When I compile the error message is that I should declare "stdafx" but the three "using" lines should obviate the need for a declaration of "stdafx" I would have thought.

I have decided to concentrate on native C++ and C++/CLI types for the moment but it is not clear which type is being used in this construction. Not that it should make any difference on thos occasion---as I understand page 100.

I appreciate your willingness to work with me in learning C++. Perhaps I will have something more to contribute as we move on----in the early stages C and C++ are very similar.

Regards

Cliff
  #7 (permalink)  
Old June 10th, 2012, 01:08 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Cliffhassall,

Well ... I was planning to do some troubleshooting with different methods used to open a new project to pinpoint the source of your error message. That has been put on the back burner because a friend brought me a computer to work on.

If you wish to pursue my planned troubleshooting before I get to it, here is my mindset. There are a variety of ways to open a new project: Win32, CLR, console application, empty project, with/without precompiled headers. I intend to different project parameters until I receive the error you encountered. The project parameters creating the error will be revealed using this mindset. (I hope.)

I successfully coded, compiled, and ran EX3_01. The project was Win32 console as an empty project (not using precompiled headers). I encountered no errors during the build. Additionally I did not use any short cut keys. My intent is to use various methods to create a new project in an attempt to receive the error which prompted you to start this thread. Experience with this sort of troubleshooting can come in very handy when writing more advanced programs. It can quickly point to errors which are not a factor of the code written. (If the error is in the project set up and not the code, no coding error will be found.)

If you arrive at a solution before I do, please let me know. Otherwise I will let you know.

drpepper
  #8 (permalink)  
Old June 11th, 2012, 04:47 AM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ivor Horton's book

Dear drpepper.
You say "There are a variety of ways
to open a new project: Win32, CLR, console application,
empty project, with/without precompiled .

This is one of the cririticisms I have of the book so far. When does one use which and why? In fact I used the C++/CLI setup.

However I will continue trying later today

Regards

Cliff
  #9 (permalink)  
Old June 11th, 2012, 12:44 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi Cliffhassall,

Your last reply provided me with the info needed to point out the source of your error codes in both Chapter 2 and Chapter 3.

The code as written in Ex3_01 is intended for a Win32 Console project created as an empty project. For the code to work in C++/CLI you must include stdafx and use namespaces. An empty win32 Console project does not use stdafx (at all) or namespaces (at our current level in the book).

how to tell which to use(??):
There are two ways to tell. One way is in the book somewhat abstractly. I have found that Chapters 2 and 3 (and I expect future chapters) begin with C++ concepts and examples. When the book moves on to C++/CLI, both the topic headings in bold and the examples include the text "C++/CLI". If you use C++ until you reach the C++/CLI sections, I believe your problem will be resolved.

The second way is one I have found to be helpful to aid my understanding, but requires a little work. If you reconstruct the method I explain here by going back to Chapter 1, I am sure that you gain the same understanding.

I created each of the projects. I expanded each of the items in Solution Explorer (the left pane) looking for code in the text editor (right pane). If I found code, I printed it out. (There is a way to include line numbers which I will explain if you wish.) I used these printed codes to make notes about the differences and the step-wise process to create the project the code is written in. Chapter 1 tells you exactly how and why to use each method.

After reading my notes and printed code for a few of the examples when opening a project and typing code (whether I need to or not), the big picture became more clear. I even went one step beyond. In the Win32 Console I created both empty projects and projects with precompiled headers. Using the methods I explained in the previous paragraph, I found some very enlightening differences between the two. Yes, I printed the code for reference and wrote notes on the printed document.

I truly believe that you will overcome the criticisms and confusion about the way the book is laid out. If you thirst for an understanding of how this book is laid out and how the various versions of C++ work, the time invested to use the same methods I have used will satisfy that thirst.

Forgive me for being redundant, but I have been tutoring for well over 40 years. The experience gained by tutoring has taught me more about the learning process than most of the teachers and professors I have studied under have exhibited in the classroom.

I have a passion for teaching. What I am picking up is that you are in a hurry. Slow down a little bit. If you have the patience, I can help you gain an understanding which is far greater than the ability to just write code which may or may not work as intended. This understanding will help you find errors more easily and eliminate a lot of frustration.

Life has taught me that knowing how to learn is more important than what you learn. If you know how to learn, you will learn new topics with greater ease. I can help you with that.

Are you game? ... If so, let's do it!

regards,
drpepper
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Visual Studio 2010 vbboyd ASP.NET 4 General Discussion 0 January 26th, 2012 06:41 PM
Visual Studio 2010 in Focus at Great Indian Developer Summit 2010 shaguf5575 ASP.NET 1.x and 2.0 Application Design 0 February 24th, 2010 07:03 AM
Visual Studio 2010 in Focus at Great Indian Developer Summit 2010 shaguf5575 ASP.NET 1.x and 2.0 Application Design 0 February 24th, 2010 07:02 AM



All times are GMT -4. The time now is 04:10 AM.


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