Advanced Inheritance 557
16
138: private:
139: PartNode * pHead;
140: int itsCount;
141: static PartsList GlobalPartsList;
142: };
143:
144: PartsList PartsList::GlobalPartsList;
145:
146:
147: PartsList::PartsList():
148: pHead(0),
149: itsCount(0)
150: {}
151:
152: PartsList::~PartsList()
153: {
154: delete pHead;
155: }
156:
157: Part* PartsList::GetFirst() const
158: {
159: if (pHead)
160: return pHead->GetPart();
161: else
162: return NULL; // error catch here
163: }
164:
165: Part * PartsList::operator[](int offSet) const
166: {
167: PartNode* pNode = pHead;
168:
169: if (!pHead)
170: return NULL; // error catch here
171:
172: if (offSet > itsCount)
173: return NULL; // error
174:
175: for (int i=0;i<offSet; i++)
176: pNode = pNode->GetNext();
177:
178: return pNode->GetPart();
179: }
180:
181: Part* PartsList::Find(
182: int & position,
183: int PartNumber) const
184: {
185: PartNode * pNode = 0;
186: for (pNode = pHead, position = 0;
187: pNode!=NULL;
188: pNode = pNode->GetNext(), position++)
189: {
LISTING16.5 continued