| | 19 | |
| | 20 | |
| | 21 | |
| | 22 | The following example uses the class-tree below. |
| | 23 | |
| | 24 | {{{ |
| | 25 | #!cpp |
| | 26 | new A1(); |
| | 27 | new A1(); |
| | 28 | new A1(); |
| | 29 | |
| | 30 | new A3(); |
| | 31 | new A3B1(); |
| | 32 | new A3B1C1(); |
| | 33 | |
| | 34 | int count = 0; |
| | 35 | for (ObjectListIterator<BaseObject> it = ObjectList<BaseObject>::begin(); |
| | 36 | it != ObjectList<BaseObject>::end(); ++it) |
| | 37 | { |
| | 38 | count++; |
| | 39 | } |
| | 40 | std::cout << "BaseObject: " << count << std::endl; |
| | 41 | |
| | 42 | count = 0; |
| | 43 | for (ObjectListIterator<A1> it = ObjectList<A1>::begin(); |
| | 44 | it != ObjectList<A1>::end(); ++it) |
| | 45 | { |
| | 46 | count++; |
| | 47 | } |
| | 48 | std::cout << "A1: " << count << std::endl; |
| | 49 | |
| | 50 | count = 0; |
| | 51 | for (ObjectListIterator<A3B1> it = ObjectList<A3B1>::begin(); |
| | 52 | it != ObjectList<A3B1>::end(); ++it) |
| | 53 | { |
| | 54 | count++; |
| | 55 | } |
| | 56 | std::cout << "A3B1: " << count << std::endl; |
| | 57 | |
| | 58 | /* |
| | 59 | return: |
| | 60 | BaseObject: 6 |
| | 61 | A1: 3 |
| | 62 | A3B1: 2 |
| | 63 | */ |
| | 64 | }}} |
| | 65 | |
| | 66 | [[Image(Core:testclass_tree.gif)]] |