------------------------------- readme.txt 9 September 1999 ------------------------------- Stroustrup defines a C++ program generally as a collection of files. These files have to be managed. The files in this directory are assigments (pdf) and C++ files for the assignments and examples. I shall sometimes provide declarations of functions or classes in an x.h file, and ask in an assignment for the corresponding definitions in x.cpp, and, perhaps, a demo file xtest.cpp which would test the code written. For a small assignment, it may be simplest to use the includes #include "w.h" #include "x.h" #include "x.cpp" at the top of the test file xtest.cpp, rather than to constuct a make file, or put everything into a project. For very short one-shot examples, it may be more convenient to put the declarations and definitions together into one include file called x.h, or even write them in at the top of the xtest.cpp file. In the later assignments, our focus will gradually shift from low-level computing and numerical issues to the mathematical problems that are to be solved. The examples have been written so that I can refer to them in class, and so that students can try them out later, at their convenience. The topic of an example is suggested by its file name. The idea is to have some code to play with that will actually compile and run. A minimal amount of comment is included: it is assumed that students have access to books which describe the elements of the language in detail. Some books are described in the annotated Reading List. Advice: don't get very involved with perfecting your own version of w.h (or win.h) because with graphics all the IO features will have to be drastically revised, to comply with Windows; once you become accustomed to graphics, a purely textual environment may appear rather dull; moreover, many mathematical problems lend themselves naturally to graphical exploration. -------------------- Graphics -------------------- All the code not involving graphics is intended to be generic: it should compile and run in any contemporary C++ environment. However, once we introduce graphics, say by means of the include files gwtiny.h and gwtiny.cpp, the situation changes because of our particular decision to use Microsoft Windows. More comments about this choice may be found in the above include files, in the demo files {gtiny.h, gtiny.rc, gtiny.cpp}, and in the annotations to some of the books under Computing in the Reading List. There are enough files in the graphics situation to justify the use of a project. Each C++ implementation has its own scheme for the handling of files in a project. Below, for example, are detailed instructions how to 'insert' the 5 files of the gtiny example into a project under Borland C++ 4.5. The 5 files mentioned are not in this directory, they may be found under Miscellaneous Downloads; the already-compiled gtiny.exe file is also given, so that you can see how it is supposed to work. ----------------------------------- The Project gtiny ----------------------------------- Example of how to create a project under Borland C++ 4.5 (1) md gtiny (somewhere on a hard drive) (2) Copy to this directory the five files gwtiny.h gwtiny.cpp gtiny.h gtiny.rc gtiny.cpp (3) From the IDE choose Project/New Project Enter ...\gtiny\gtiny The first gtiny is the directory created above; the second is the name of the project. De-select OWL (we don't need this library). Select Static (rather than dynamic) otherwise your .exe file will need BC450RTL.DLL to run. Select Class library. On exit you see two panes: the higher one is blank, and below you see a tree for the project which anticipates gtiny.exe, gtiny.h, gtiny.rc, gtiny.cpp; but at the moment these files are blank. Delete all but gtiny.exe with the [DEL] key. (4) In the lower pane, highlight gtiny.exe, then press [INS]. A file window comes up. Now insert the five files. You can do this in one shot by pressing [CTRL] while selecting additional files, so that all five are highlighted and then inserted. (5) Now select Run from Debug and the project will compile and run. Keep this whole subdirectory intact, as a model. Don't forget to close the project before you exit Turbo C++. Note that the subdirectory gtiny has the file gtiny.exe which will run alone provided you selected static at the start. (6) When you want to make your own project you can simply copy the three project files gtiny.h, gtiny.rc, and gtiny.cpp to new names, say, g1.h, g1.rc, g1.cpp, and put them in their own subdirectory g1, along with the two library files gwtiny.h and gwtiny.cpp. You can then modify g1.* to suit the needs of your project. Advice: don't tamper with gwtiny.h or gwtiny.cpp until you are confident enough to do so. Richard Hall