list.h

来自「一本语言类编程书籍」· C头文件 代码 · 共 32 行

H
32
字号
// List.h classes supporting a linked list
#ifndef LIST_H
#define LIST_H

#include "Box.h"

class TruckLoad {
  public:
    TruckLoad(Box* pBox = 0, int count = 1);   // Constructor
    TruckLoad(const TruckLoad& load);          // Copy constructor

    Box* getFirstBox();                        // Retrieve the first Box
    Box* getNextBox();                         // Retrieve the next Box
    void addBox(Box* pBox);                    // Add a new Box to the list

  private:
    // Class defining a list element
    class Package {
      public:
        Box* pBox;                                 // Pointer to the Box
        Package* pNext;                            // Pointer to the next Package

        void setNext(Package* pPackage);           // Add package to end of list
        Package(Box* pNewBox);                     // Constructor  
    };
 
    Package* pHead;                            // First in the list
    Package* pTail;                            // Last in the list
    Package* pCurrent;                         // Last retrieved from the list
};
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?