Exercises


Exercise 20.1: Using Visual Studio help

Use help to look up the 'macro function' COLORREF RGB( BYTE bRed, BYTE bGreen, BYTE bBlue) . (A macro function is a global function that has a short inline code definition that is actually substituted for each call to the function.) Now use help to look up something more elaborate. Look at the documentation on CDC .

Exercise 20.2: Putting a version number into the name of the executable

Even though your successive versions of your program are going to live in separate directories, it's a good idea to put a number after the name of each executable, and to include the date. Change your Pop project settings so that the names of your Debug and Release output files will include today's date. For information about the controls to use, look at the table in Appendix C. (Although we already discussed this in Exercise 3.4, it's important enough to go over it again.)

Exercise 20.3: What happens if you forget some includes?

When you are making new class files you'll sometimes forget to put in a necessary include. In this exercise we look at the kinds of error messages you get so that when you see them again you may hopefully remember that the problem is a missing include file. First, try commenting out the line #include "force.h" in the critter.cpp file. If you build, you get error messages similar to 'cForce' : no appropriate default constructor available . Put the line back in. Second, try commenting out the line #include "game.h" in the same file. This time you'll get messages like use of undefined type 'cBiota'. As it turns out, the game.h file has an #include "biota.h" in it, so when we lose game.h , we lose biota.h as well. Put the line back. Third, try commenting out the line #include " randomizer .h" at the start of the header file critter.h. When you try and build you get more than 80 error messages. Some of them say things like left of '.randomReal' must have class/struct/union type . This kind of line can be seem cryptic to a beginner. The compiler is trying to say that you are using an object that belongs to a class that you haven't defined by including the proper header file for it.

Exercise 20.4: Browsing in the afxwin.h include file

Use the Start Find command to find afxwin.h . On the author's computer it lives in C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include. Click on the file to open it inside of Visual Studio, and if this doesn't work, start a Visual Studio session and open the file using the File Open command. Look through the file, and press F1 on any words or symbols you wonder about. Note that CPoint is defined in here.



Software Engineering and Computer Games
Software Engineering and Computer Games
ISBN: B00406LVDU
EAN: N/A
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net