运行窗口老是崩溃!解决办法

运行窗口老是崩溃!!
//prog13_01.cpp

#include<iostream>
#include<cstdlib>
#include<ctime>

using namespace std;
using std::cout;
using std::endl;

#include"Box.h"
#include"List.h"

inline int random(int count){

  return 1+static_cast<int>
  (count*static_cast<double>(rand())/(RAND_MAX+1.0));
}

int main(){
  const int dimLimit=100; //设置Box的上限
  srand((unsigned)time(0)); // 初始化随机数

  //创建一个空链表
  TruckLoad load1;

  //添加10个随机尺寸的Box到链表
  for(int i=0;i<0;i++)
  load1.addBox(new Box(random(dimLimit),random(dimLimit),random (dimLimit)));
  //找到最大的Box
  Box* pBox=load1.getFirstBox();
  Box* pNextBox;
  while(pNextBox=load1.getNextBox())
  if(pBox->compareVolume(*pNextBox)<0)
  pBox=pNextBox;
  cout<<endl
  <<"The largest box in the first list is "
  <<pBox->getLength()<<" by "
  <<pBox->getWidth()<<" by "
  <<pBox->getHeight()<<endl;

  const int boxCount=20; //Box数组的大小
  Box boxes[boxCount]; //Box数组对象
   
  for(int j=0; j<boxCount;j++)
  boxes[j]=Box(random(dimLimit),random(dimLimit),random(dimLimit));
   
  TruckLoad load2(boxes,boxCount);

  pBox=load2.getFirstBox();
  while(pNextBox=load2.getNextBox())
  if(pBox->compareVolume(*pNextBox)<0)
  pBox=pNextBox;

  cout<<endl
  <<"The largest box in the second list is "
  <<pBox->getLength() << " by "
  <<pBox->getWidth() <<" by "
  <<pBox->getHeight() <<endl;

  //删除第一个链表的Box对象
  pNextBox=load1.getFirstBox();
  while(pNextBox){
  delete pNextBox;
  pNextBox=load1.getNextBox();
 }
return 0;
}
  

运行这个程序窗口老是崩溃 是怎么回事啊?
等高手。。。

------解决方案--------------------
太长了懒得看啊,打酱油,帮顶的……
------解决方案--------------------
一般情况基本上有两种:野指针和数组越界;