CodeCodeCode

DLL

Dec 12th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. //StuffDLL.h
  2.  
  3. #ifdef STUFFDLL_EXPORTS
  4. #define STUFFDLL_API __declspec(dllexport)
  5. #else
  6. #define STUFFDLL_API __declspec(dllimport)
  7. #endif
  8.  
  9. namespace Stuff {
  10.     class StuffMath {
  11.     public:
  12.         template<class T> static STUFFDLL_API T Ad(T a, T b);
  13.         static STUFFDLL_API double Add(double a, double b);
  14.     };
  15. }
  16.  
  17. // StuffDLL.cpp : Defines the exported functions for the DLL application.
  18. //Turn off "precompiled headers"
  19.  
  20. #include "StuffDLL.h"
  21. #include <stdexcept>
  22.  
  23. using namespace std;
  24.  
  25. namespace Stuff {
  26.     double StuffMath::Add(double a, double b) {
  27.         return (a + b);
  28.     }
  29.  
  30.     template<class T>
  31.     T StuffMath::Ad(T a, T b) {
  32.         return(a + b);
  33.     }
  34. }
  35.  
  36. // DLLExec.cpp : Defines the entry point for the console application.
  37.  
  38. #include <iostream>
  39. #include <Windows.h>
  40. #include "StuffDLL.h"
  41.  
  42. using namespace std;
  43.  
  44. int main() {
  45.     cout << "a + b = " << Stuff::StuffMath::Ad(2, 3) << endl;
  46.  
  47.     system("pause");
  48.     return(0);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment