#include
class CMy_Math
{
public:
CMy_Math();
~CMy_Math();
double add(double a,double b); //加法
double div(double a,double b);//除法
double subtract(double a,double b);//減法
double mult(double a,double b); //乘法
};
CMy_Math::CMy_Math()
}
CMy_Math::~CMy_Math()
double CMy_Math::add(double a,double b)
return a+b;
double CMy_Math::subtract(double a,double b)
return a-b;
double CMy_Math::mult(double a,double b)
return a*b;
double CMy_Math::div(double a,double b)
if ( 0.0 != b)
//b不能為0.0
return a/b;
int main(double argc, char* argv[])
CMy_Math my;
double sum=0;
sum= my.add(10,5);
cout
sum= my.subtract(10,5);
sum= my.div(10,5);
return 0;
#include
class CMy_Math
{
public:
CMy_Math();
~CMy_Math();
public:
double add(double a,double b); //加法
double div(double a,double b);//除法
double subtract(double a,double b);//減法
double mult(double a,double b); //乘法
};
CMy_Math::CMy_Math()
{
}
CMy_Math::~CMy_Math()
{
}
double CMy_Math::add(double a,double b)
{
return a+b;
}
double CMy_Math::subtract(double a,double b)
{
return a-b;
}
double CMy_Math::mult(double a,double b)
{
return a*b;
}
double CMy_Math::div(double a,double b)
{
if ( 0.0 != b)
//b不能為0.0
return a/b;
}
int main(double argc, char* argv[])
{
CMy_Math my;
double sum=0;
sum= my.add(10,5);
cout
sum= my.subtract(10,5);
cout
sum= my.subtract(10,5);
cout
sum= my.div(10,5);
cout
return 0;
}