next up previous
Next: Hardware Store Up: C++ Advanced Course Previous: Dictionary

Style examples

Most likely you won't only meet with C++ when you create a new program from scratch. It is highly possible you will inherit C++ code from others, and you should understand, analyze, fix and/or modify these sources.

Therefore it is important for you being able to understand others way of thinking - presented in C++ lines. You should decide which elements of that code is correct, and which elements are overcomplicated or simple mistakes. At the end you should correct the program.

Here we present three examples of this kind. Each of them is "correct" in the meaning that you can compile them and they produce the expected output. But they are not perfect at all. Several kind of mistakes may lay in these programs, from design issues to technicalities.

I have put 3 independent projects under style-1, style-2 and style-3 directories. In each directories You can read the goal of the programs in the version with suffix 'a.cpp' (eg. style-1a.cpp).

Your job is to analyze the examples, and try to improve the solutions. In the other files (eg. style-1b.cpp) you can find improved versions to get a hint, what to do. Please, look at those files only in "case of emergency".



Subsections
next up previous
Next: Hardware Store Up: C++ Advanced Course Previous: Dictionary
Porkoláb Zoltán 2001-09-03