Advertisement
TheWhiteFang

DLLGeo Source Files

Jan 16th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.57 KB | None | 0 0
  1. //DLLGeo source files
  2. #include "CubeGeometricCalc.h"
  3.  
  4. //Defining member function outside of class
  5. void CubeGeometricCalc :: SetGeometricAttributes(float inSide1, float inSide2, float inRadius){
  6.  
  7.     m_Side = inSide1;
  8.     m_Height = inSide2;
  9.     m_Radius = inRadius;
  10. }
  11.  
  12.  
  13. float CubeGeometricCalc :: CalculateSurfaceArea()
  14. {
  15.     /*m_SurfaceArea = m_Side*m_Height;*/
  16.     return(6 * m_Side*m_Height);
  17. };
  18.  
  19. float CubeGeometricCalc :: CalculateVolume()
  20. {
  21.     /*m_Volume = m_Side*m_Side*m_Height;*/
  22.     return(m_Side*m_Side*m_Height);
  23. };
  24. ---------------------------------------------------------------
  25. //cylindergeometriccalc
  26. #include "CylinderGeometricCalc.h"
  27.  
  28.  
  29. //Defining member function outside of class
  30. void CylinderGeometricCalc :: SetGeometricAttributes(float inSide1, float inSide2, float inRadius){
  31.  
  32.     m_Side = inSide1;
  33.     m_Height = inSide2;
  34.     m_Radius = inRadius;
  35. };
  36.  
  37. float CylinderGeometricCalc:: CalculateSurfaceArea()
  38. {
  39.     /*m_SurfaceArea = (2*PI*m_Radius*m_Height)+(2*PI*m_Radius*m_Radius);*/
  40.     return((2 * PI*m_Radius*m_Height) + (2 * PI*m_Radius*m_Radius));
  41. };
  42.  
  43. float CylinderGeometricCalc::CalculateVolume()
  44. {
  45.     /*m_Volume = PI*m_Radius*m_Radius*m_Height;*/
  46.     return(PI*m_Radius*m_Radius*m_Height);
  47. };
  48. --------------------------
  49. //DLLGeo.cpp
  50. #include <iostream>
  51. using namespace std;
  52.  
  53. // IMPORTANT: DLLTEST_API will perform an export of the exposed functions
  54. #define DLL_EXPORT
  55.  
  56. // Include the header, must come after #define DLL_EXPORT
  57. #include "DLLGeo.h"
  58. #include "CubeGeometricCalc.h"
  59. #include "SphereGeometricCalc.h"
  60. #include "CylinderGeometricCalc.h"
  61.  
  62. extern "C"
  63. {
  64.     DLLTEST_API IGeometricCalc* NewObject(int operation)
  65.     {
  66.         if (operation == 0){
  67.  
  68.             return new CubeGeometricCalc();
  69.         }
  70.         else if (operation == 1){
  71.             return new SphereGeometricCalc();
  72.         }
  73.         else if (operation == 2){
  74.             return new CylinderGeometricCalc();
  75.         }
  76.         else{
  77.             return NULL;
  78.         }
  79.     }
  80.  
  81.     DLLTEST_API void DelObject(IGeometricCalc *pObject)
  82.     {
  83.         delete pObject;
  84.     }
  85. }
  86. -----------------------------------
  87. //spheregeometriccalc.h
  88. #include "SphereGeometricCalc.h"
  89.  
  90.  
  91. //Defining member function outside of class
  92. void SphereGeometricCalc:: SetGeometricAttributes(float inSide1, float inSide2, float inRadius){
  93.  
  94.     m_Side = inSide1;
  95.     m_Height = inSide2;
  96.     m_Radius = inRadius;
  97. }
  98.  
  99. float SphereGeometricCalc :: CalculateSurfaceArea()
  100. {
  101.     /*m_SurfaceArea = 4*PI*m_Side*m_Side;*/
  102.     return(4.0 * PI*m_Radius*m_Radius);
  103. };
  104.  
  105. float SphereGeometricCalc :: CalculateVolume()
  106. {
  107.     /*m_Volume = (4.0/3.0)*PI*m_Radius*m_Radius*m_Radius;*/
  108.     return((4.0 / 3.0)*PI*m_Radius*m_Radius*m_Radius);
  109. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement