An object declared using a pointer

Header File: Box.h

#if !defined VolumesH

#define VolumesH



namespace Volumes

{

class TBox

{

public:

    TBox(double L = 0, double H = 0, double W = 0);

    TBox(const TBox &Box);

    ~TBox();



    void setLength(const double L) { Length = L; }

    double getLength() const { return Length; }

    void setHeight(const double H) { Height = H; }

    double getHeight() const { return Height; }

    void setWidth(const double W) { Width = W; }

    double getWidth() const { return Width; }

    void setDimensions(const double L, const double H, const double W);



    double Area() const;

    double Volume() const;



private:

    double Length;

    double Height;

    double Width;

};

}



#endif	// VolumesH

Source File: Box.cpp

#include "Volumes.h"



namespace Volumes

{

TBox::TBox(double L, double H, double W)

	: Length(L), Height(H), Width(W)

{

}



TBox::TBox(const TBox &Box)

	: Length(Box.Length),

      Height(Box.Height),

	  Width(Box.Width)

{

}



TBox::~TBox()

{

}



void TBox::setDimensions(const double L, const double H, const double W)

{

	setLength(L);

	setHeight(H);

	setWidth(W);

}



double TBox::Area() const

{

	return 2 * ( (Length * Height) +

		         (Height * Width) +

		         (Length * Width) );

}



double TBox::Volume() const

{

    return Length * Height * Width;

}



}    // namespace Volumes

Source File: Main.cpp

#include <iostream>

#include "Volumes.h"



using namespace std;

using namespace Volumes;



void GetDimensions(TBox *Box)

{

    double L, H, W;



    cout << "Specify the dimensions of the box\n";

    cout << "Length: "; cin >> L;

    cout << "Height: "; cin >> H;

    cout << "Width:  "; cin >> W;



    Box->setDimensions(L, H, W);

}



void ShowProperties(const TBox *Box)

{

    cout << "\nBox Properties";

    cout << "\nLength = " << Box->getLength();

    cout << "\nHeight = " << Box->getHeight();

    cout << "\nWidth  = " << Box->getWidth();

    cout << "\nArea   = " << Box->Area();

    cout << "\nVolume = " << Box->Volume() << "\n";

}



int main()

{

    TBox *Box = new TBox;



    GetDimensions(Box);

    ShowProperties(Box);



    delete Box;

    Box = NULL;



    return 0;

}