C++ Program Design: Third Edition

Jim Cohoon and Jack Davidson

  Important features
EzWindows packages
Laboratory materials
Lecture materials
Self-check solutions
Solution manual
Homework assignments


Frequently asked questions

It has been and will continue to be our policy to quickly respond to questions. However, to allow for even faster response, we are trying now to anticipate questions. This list is our newest addition, so expect that questions and answers will be added somewhat regularly.

The nongraphical examples build and run, but I cannot get the graphical programs to work. What's the problem?

Most likely you did not use a project file. The use of a project file is mandatory for such programs. The short answer regarding project files is to check out Appendix F. This appendix explains in detail how to create, use, and modify projects files. The following paragraphs drasically summarize that material.

The simple nongraphical programs of the first four chapters have the entire program in a single file. And, the only libraries that these programs use are the standard ones. Most compilers are configured to determine automatically for simple programs where the include and link libraries are located. (Some of the compilers will indicate there choices through messages stating that a default project is being created and used). These automatic/default actions will not work for programs that span multiple files or which use additional libraries such as the EzWindows library. For such programs, project files must be used.

One of the projects supplied in the various versions of the software is the lawn project. Rather than directly opening lawn.cpp to build and run the program, the lawn project file must be opened. The suffix of the lawn project file varies depending upon which compiler is being used. For example, Borland project files typically use the suffix IDE and Microsoft Visual C++ projects now use the suffix DSW.

The process of opening a project varies with different compilers. For example, Borland has a Project menu, one of whose choices is Open project; while Visual C++ users open projects using the Open Workspace choice from the File Menu.

After opening the project, several of its characteristics might need to be updated. The files that make up the project reflect where we expect the project to be located. In particular, EzWindows programs all have ezwin.lib as one of their elements. The specification of its location is relative to where we expected the project file to be placed. If you have altered the directory structure, then you must edit the .lib entry to reflect its location. In Borland, the correct location can be specified by right-clicking on the .lib entry of the Project window and selecting Edit node attributes. With Visual C++, you are required to first delete the current occurrence of the .lib entry from the project. The current occurrence can be deleted by highlighting the .lib entry and then typing the DEL key. You can then add a correctly located .lib entry by using the choice Files into project from the Insert Menu.

Besides specifying the files that make up the project, a project file also specifies the location both of the header files of the standard and EzWindows libraries, as well as the compiled versions of standard libraries.

For Borland, the directory information can be specified by selecting the choice Project of the Options menu. A dialog box will be opened, one of its entries is Directories. After selecting Directories, edit its various components to indicate where on your system both the headers and compiled versions of the libraries can be found. Also ensure that the intermediary and final directories (if specified) are acceptable and exist.

For Visual C++, the directory information can be selected by first selecting the Settings choice of the Build menu. Next select the tab C/C++. Under this tab, select the category Preprocessor. One of the resulting fields is Additional include directories. Set this field to the appropriate EzWindows include directory. Note this directory can be specified using a relative path name.

I would like to create a new program that displays graphic shapes. What steps do I need to take?

Graphical programs require project files as there are inherently multiple files used in the building of the program. There are two ways to go about creating a project file. One way is to copy an existing project file and then edits its entries so that it has proper names for the various files that will make up the program. Another method is to use the New project/workspace command of your compiler. For Borland this command is found under the Project menu. For Visual C++, the command is found under the File menu.

A graphical project file will consist of at least two files: the file which contains your function ApiMain() and the file ezwin.lib. You will also need to specify where various header and compiled library directories can be found. For information on specifying such entries check out this FAQ.

Is there a home page for your course? What materials do you keep there?

At the University of Virginia, CS 101 uses this text. At the course home page you will find normal syllabus type information and copies of the assignments for the current semester.

My program output disappears immediately after the program finishes its execution. Is there anything I can do so that the displays remain?

The following comments give suggestions for both the continued display of the graphical and console windows.

Under 16-bit Windows you can cause your graphical display to remain on your console by making the SimpleWindow object associated with the display global.

Under 16-bit and 32-bit Windows, you can also introduce a final prompt and extraction at the end of your program. This pause allows you to display the program as long as you wish.

Another technique is to run your program from a command prompt rather than from the compiler. By running from the command prompt, its window will act as your console. This window has a lifetime that extends beyond the execution of the program.