C++ closure

Took my final exam in C++ and object-oriented design today, after tossing the final project over the transom 2 days ago. The final was quite challenging: even open book/open notes, it was tough.

I find I like the design questions and problems better than the ones that rely on syntax retention. The one I found most interesting was the design of a metering/analysis tool for a freeway onramp. The object was to design the data structure to hold the information about all the cars that passed through the ramp on to a motorway, recording the time spent waiting and the number of cars.

As I saw the problem, what was needed was a structure for each car with its time in and out the ramp, any wait time, and as the car left the ramp, the object holding its information would be collected and summarized by an onRamp object.

The Car object could be a simple typedef, a struct or a methodless class.

The questions I liked least were, to my mind, quite vague: one dealt with Polygons as a class, but the class constructor seemed to use just two points — X and Y — to define a polygon. My memory of coordinate geometry is weak, but I seem to recall that a point has no dimensions, the smallest/simplest thing that can have dimensions being a line. I suspect I didn’t do too well on that one.