一、DLL部分
1、DLLTest.h
extern "C" _declspec(dllexport) float multiplex(float a, float b);
extern "C" _declspec(dllexport) float divide(float a,float b);
extern "C" _declspec(dllexport) float add(float a,float b);
extern "C" _declspec(dllexport) float subtract(float a,float b);
2、DLLTest.cpp
_declspec(dllexport) float multiplex(float a, float b)
{
return a*b;
}_declspec(dllexport) float divide(float a,float b)
{
return a/b;
}
_declspec(dllexport) float add(float a,float b)
{
return a+b;
}
_declspec(dllexport) float subtract(float a,float b)
{
return a-b;
}
二、测试用例部分
1、Link,DLLTest.lib
2、测试代码:
#include "DLLTest.h"
float a = multiplex(3,5);
CString str;
str.Format("%f",a);
AfxMessageBox(str);
本文介绍了DLL文件中四个基本数学运算函数的实现与调用过程,包括乘法、除法、加法和减法。通过具体代码示例展示了如何在DLL中导出这些函数,并在客户端代码中导入和使用它们。
609

被折叠的 条评论
为什么被折叠?



