用隐式方法调用一个计算长方体表面积和体积的类
2010-12-23 17:43
543 查看
实现函数下:
在对话框的头文件下:
#include "AreaVolumnClass.h"
#pragma comment(lib,"ExportClassDll.lib")
#if _MSC_VER >1000
#pragma once
#endif // _MSC_VER >1000
/////////////////////////////////////////////////////////////////////////////
// CUseExportClassDllDlg dialog
class CUseExportClassDllDlg : public CDialog
{
// Construction
public:
CUseExportClassDllDlg(CWnd* pParent = NULL); // standard constructor
AreaVolumnClass MyClass;
功能实现函数:
void CUseExportClassDllDlg::OnCal()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
MyClass.SetLenth(m_lenth);
MyClass.SetWidth(m_width);
MyClass.SetHeitht(m_height);
m_SurfaceArea=MyClass.GetArea();
m_Volumn=MyClass.GetVolumn();
UpdateData(FALSE);
}
被调用的文件下:(新建的AreaVolumnClass类,.h文件下)
class _declspec(dllexport) AreaVolumnClass
{
public:
void SetHeitht(double c);
void SetWidth(double b);
void SetLenth(double a);
double GetVolumn();
double GetArea();
AreaVolumnClass();
virtual ~AreaVolumnClass();
private:
double lenth;
double width;
double height;
};
实现cpp下:
// AreaVolumnClass.cpp: implementation of the AreaVolumnClass class.
//
//////////////////////////////////////////////////////////////////////
#include "AreaVolumnClass.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
AreaVolumnClass::AreaVolumnClass()
{
height=lenth=width=0.0;
}
AreaVolumnClass::~AreaVolumnClass()
{
}
double AreaVolumnClass::GetArea()
{
return 2*(height*lenth+height*width+width*lenth);
}
double AreaVolumnClass::GetVolumn()
{
return height*lenth*width;
}
void AreaVolumnClass::SetLenth(double a)
{
lenth=a;
}
void AreaVolumnClass::SetWidth(double b)
{
width=b;
}
void AreaVolumnClass::SetHeitht(double c)
{
height=c;
}
最后要注意的是:
1、那些功能函数必须一个个添加;
2、AreaVolumnClass.h必须拷到调用的工程文件中,否则出错;
在对话框的头文件下:
#include "AreaVolumnClass.h"
#pragma comment(lib,"ExportClassDll.lib")
#if _MSC_VER >1000
#pragma once
#endif // _MSC_VER >1000
/////////////////////////////////////////////////////////////////////////////
// CUseExportClassDllDlg dialog
class CUseExportClassDllDlg : public CDialog
{
// Construction
public:
CUseExportClassDllDlg(CWnd* pParent = NULL); // standard constructor
AreaVolumnClass MyClass;
功能实现函数:
void CUseExportClassDllDlg::OnCal()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
MyClass.SetLenth(m_lenth);
MyClass.SetWidth(m_width);
MyClass.SetHeitht(m_height);
m_SurfaceArea=MyClass.GetArea();
m_Volumn=MyClass.GetVolumn();
UpdateData(FALSE);
}
被调用的文件下:(新建的AreaVolumnClass类,.h文件下)
class _declspec(dllexport) AreaVolumnClass
{
public:
void SetHeitht(double c);
void SetWidth(double b);
void SetLenth(double a);
double GetVolumn();
double GetArea();
AreaVolumnClass();
virtual ~AreaVolumnClass();
private:
double lenth;
double width;
double height;
};
实现cpp下:
// AreaVolumnClass.cpp: implementation of the AreaVolumnClass class.
//
//////////////////////////////////////////////////////////////////////
#include "AreaVolumnClass.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
AreaVolumnClass::AreaVolumnClass()
{
height=lenth=width=0.0;
}
AreaVolumnClass::~AreaVolumnClass()
{
}
double AreaVolumnClass::GetArea()
{
return 2*(height*lenth+height*width+width*lenth);
}
double AreaVolumnClass::GetVolumn()
{
return height*lenth*width;
}
void AreaVolumnClass::SetLenth(double a)
{
lenth=a;
}
void AreaVolumnClass::SetWidth(double b)
{
width=b;
}
void AreaVolumnClass::SetHeitht(double c)
{
height=c;
}
最后要注意的是:
1、那些功能函数必须一个个添加;
2、AreaVolumnClass.h必须拷到调用的工程文件中,否则出错;
相关文章推荐
- 编写一个计算长方体体积的C#WindowsForm,包含一个类,一个方法,三个属性
- 计算长方体、四棱锥的表面积和体积
- 计算长方体、四棱锥的表面积和体积
- 【java学习记录】2.定义一个计算矩形面积、立方体和球体体积的类,该类完成计算的方法用静态方法实现
- 计算长方体、四棱锥的表面积和体积
- 写4个同名方法,实现两个整数、两个实数,一个实数一个整数,一个整数一个实数之间的求和。在主调函数中调用这4个方法计算相关的值。(方法的重载)
- 第三周任务4:用类计算长方体的表面积和体积
- sdut_java_计算长方体、四棱锥的表面积和体积
- 计算长方体、四棱锥的表面积和体积
- 以太坊代币开发计算调用一个合约方法需要消耗多少gas
- 计算长方体、四棱锥的表面积和体积
- SDUT 3337 计算长方体、四棱锥的表面积和体积
- JAVA之设计一个立方体类Cube,只有边长属性,计算表面积和体积
- 编写一个方法,计算kkk^^kk (共n个k,n>0)的值。例如k=2,n=5则为22222。调用方法求s1=6+66+666+6666+66666
- 计算长方体、四棱锥的表面积和体积(java)
- Java sdut acm 3337 计算长方体、四棱锥的表面积和体积
- 设计一个圆柱体类,计算表面积及体积。建立一个半径为3、高为3.5的圆柱体,输出其表面积及体积
- 计算长方体、四棱锥的表面积和体积(Java)acm.sdut
- 计算长方体、四棱锥的表面积和体积
- 计算长方体、四棱锥的表面积和体积