View Single Post
  #1 (permalink)  
Old March 4th, 2007, 02:33 PM
Chacko Chacko is offline
Registered User
 
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default errors during run-time

below are the errors, the line numbers and also the file of error.

/*Box.cpp*/

double Box::volume()
{
----> return length*breadth*height;
}

/*Box.cpp*/

int Box::compareVolume(Box &otherBox)
{
----> double vol1 = volume();
    double vol2 = otherBox.volume();
    return vol1>vol2?1:(vol1<vol2?-1:0);
    return 0;
}

/*CConApp95.cpp*/


    const int dimLimit = 100;

    TruckLoad load1;

    for(int i=0;i<10;i++)
    {
        load1.addBox(new Box(random(dimLimit), random(dimLimit), random(dimLimit)));
    }

    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->getBreadth()<<" by "
        <<pBox->getHeight()<<endl;

    const int boxCount = 20;

    Box boxes[boxCount];

    for(int i=0;i<boxCount;i++)
    {
        boxes[i] = 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->getBreadth()<< " by "
        <<pBox->getHeight()<<endl;

    pNextBox = load1.getFirstBox();

    while(pNextBox)
    {
        delete pNextBox;
        pNextBox = load1.getNextBox();
    }

    return 0;
}

thank you

Reply With Quote