While looking at some old C and C++ programs, I found that the structs could be drawn as class diagrams in UML showing composition and aggregation as shown in the following paragraphs.
Aggregation |
|
struct Shopping_Basket
{
Item *itemPtr;
:
:
}
|
The shopping basket does not need to have items in it for it to be a shopping basket. Both shopping basket and item can exist independantly. The item pointer is shown with an open diamond. Here the shopping basket is like an array, e.g. Shopping_Basket[] which even when empty is still an array.
|
|
Composition |
|
struct OrderForm
{
orderLine linePtr;
:
:
}
|
An order form is not a form without lines. The order form gives instances of order lines. If an order line does not exist, then there is no order. The line pointer is shown with black filled in diamond.
(c) B V Wood.
|