Advertisement
TheWhiteFang

Source Files for DLLArith

Jan 15th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. //DLLArith - These are all the Source Files for DLLArith
  2. //Add.cpp
  3.  
  4. #include "Add.h"
  5.  
  6. // Defining a member function outside of class
  7. int Add::Calc(int v1, int v2)
  8. {
  9.     return v1+v2;
  10. }
  11. -----------------------------------------------------------------------------
  12. //DLLArith.cpp
  13. #include <iostream>
  14. using namespace std;
  15.  
  16. // IMPORTANT: DLLTEST_API will perform an export of the exposed functions
  17. #define DLL_EXPORT
  18.  
  19. // Include the header, must come after #define DLL_EXPORT
  20. #include "DLLArith.h"
  21. #include "Add.h"
  22. #include "Subtract.h"
  23.  
  24. extern "C"
  25. {
  26.     DLLTEST_API IArith* NewObject(int operation)
  27.     {
  28.         if(operation == 0){
  29.  
  30.             return new Add();
  31.         }
  32.         else if(operation == 1){
  33.             return new Subtract();
  34.         }
  35.         else{
  36.             return NULL;
  37.         }
  38.     }
  39.  
  40.     DLLTEST_API void DelObject(IArith *pObject)
  41.     {
  42.         delete pObject;
  43.     }
  44. }
  45. ------------------------------------------------------------------------
  46. // Subtract.cpp
  47. #include "Subtract.h"
  48.  
  49. // Defining a member function outside of class
  50. int Subtract::Calc(int v1, int v2)
  51. {
  52.     return v1-v2;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement