21.2 windows_21_Library_Class_DLL_USE 动态库补充2

windows_21_Library_Class_DLL_USE 动态库补充2

  1. // windows_21_Library_Class_DLL_USE.cpp : 定义控制台应用程序的入口点。
  2. //
  3. #include "stdafx.h"
  4. //导入DLL文件
  5. #pragma comment(lib,"../bin/windows_21_Library_Class_DLL.lib")
  6. //需要声明一个类的定义,还需要导入类__declspec( dllimport )
  7. class __declspec( dllimport )CMath
  8. {
  9. public:
  10. int Add( int nAdd1, int nAdd2 );
  11. int Sub( int nSub1, int nSub2 );
  12. };
  13. int _tmain(int argc, _TCHAR* argv[])
  14. {
  15. //使用类
  16. CMath math;
  17. int nAdd = math.Add( 100, 100 );
  18. int nSub = math.Sub( 100, 100 );
  19. printf( "nAdd:%d\nnSub:%d\n", nAdd, nSub );
  20. return 0;
  21. }





posted @ 2016-06-10 09:49  -刀狂剑痴-  阅读(156)  评论(0编辑  收藏  举报