Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 4th, 2007, 02:33 PM
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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Run time errors Martin Outlaw Excel VBA 2 August 23rd, 2006 05:13 AM
Design-Time or Run-Time now ? ALGNET .NET Framework 2.0 1 July 31st, 2006 04:43 AM
RUN-TIME ERRORS IN MY VB6 APPLICATION Nadalik VB How-To 1 June 15th, 2006 11:18 AM
Run time Help Dazzer96 Access VBA 2 May 3rd, 2006 07:03 AM
Run Time Customization B.V.Madhav Crystal Reports 1 May 10th, 2005 01:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.