2、
#include "targetver.h"
// dlltest.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include "stdafx.h"
#include "targetver.h"
//#include <iostream>
//using namespace std;
int Add(int plus1, int plus2)
{
int add_result = plus1 + plus2;
return add_result;
}
namespace zdd
{
SimpleDll::SimpleDll()
{
}
SimpleDll::~SimpleDll()
{
}
int SimpleDll::add(int x, int y)
{
return x+y;
}
}
namespace ch{
int sub(int x,int y)
{
return x-y;
}
int chmutable(int x,int y)
{
return x*y;
}
}
dlltest,cpp
// dlltest.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include "stdafx.h"
#include "targetver.h"
//#include <iostream>
//using namespace std;
int Add(int plus1, int plus2)
{
int add_result = plus1 + plus2;
return add_result;
}
namespace zdd
{
SimpleDll::SimpleDll()
{
}
SimpleDll::~SimpleDll()
{
}
int SimpleDll::add(int x, int y)
{
return x+y;
}
}
namespace ch{
int sub(int x,int y)
{
return x-y;
}
int chmutable(int x,int y)
{
return x*y;
}
}
使用:
#include "stdafx.h"
#include "..\dlltest\exportdll.h"
#pragma comment(lib,"../Debug/dlltest.lib")
int _tmain(int argc, _TCHAR* argv[])
{
int x = Add(1,2);
zdd::SimpleDll dll;
int y= dll.add(1,3);
y = ch::sub(3,5);
y = ch::chmutable(3,5);
return 0;
}
源码下载 https://download.youkuaiyun.com/download/u010261063/10314998