- 论坛徽章:
- 0
|
Cube.cpp
#include "Cube.h"
#include <iostream>;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCube::CCube(double l,double w,double h)
{
try
{
m_dfL=l;
m_dfW=w;
m_dfH=h;
float m=0/0;
m_dfL=m;
}
catch(...)
{
std::cout<<"0/0"<<std::endl;
}
}
CCube::~CCube()
{
}
double CCube::GetBulk()
{
return m_dfL*m_dfW*m_dfH;
}
Main.cpp
#include <iostream>;
#include <Circle.h>;
#include <Cube.h>;
using namespace std;
int main(int argc,char *argv[])
{
CCircle circle(5);
CCube cube(6.0,7.0,8.0);
cout<<"aaaa"<<endl<<"diam"<<circle.GetDiameter()<<endl<<"Area"<<circle.GetArea()<<endl<<"Bulk"<<cube.GetBulk()<<endl;
}
程序输出:
[zgm@localhost test2]$ ./dir1/prog1
Floating point exception |
|