-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding example and fix to parsing of double/float types!
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
342 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
all: | ||
g++ -g -Wall -fPIC -shared -o libmath-v1.so MathLibrary.cpp | ||
g++ -g -Wall -fPIC -shared -o libmath-v2.so MathLibraryChanged.cpp | ||
g++ -g -Wall -o math-client MathClient.cpp -I . -L. libmath-v1.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// MathClient.cpp | ||
// compile with: cl /EHsc MathClient.cpp /link MathLibrary.lib | ||
|
||
#include <iostream> | ||
#include "MathLibrary.h" | ||
|
||
int main() | ||
{ | ||
double a = 7.4; | ||
int b = 99; | ||
|
||
std::cout << "a + b = " << | ||
MathLibrary::Arithmetic::Add(a, b) << std::endl; | ||
std::cout << "a - b = " << | ||
MathLibrary::Arithmetic::Subtract(a, b) << std::endl; | ||
std::cout << "a * b = " << | ||
MathLibrary::Arithmetic::Multiply(a, b) << std::endl; | ||
std::cout << "a / b = " << | ||
MathLibrary::Arithmetic::Divide(a, b) << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// MathLibrary.cpp | ||
// compile with: cl /c /EHsc MathLibrary.cpp | ||
// post-build command: lib MathLibrary.obj | ||
|
||
#include "MathLibrary.h" | ||
|
||
namespace MathLibrary | ||
{ | ||
double Arithmetic::Add(double a, double b) | ||
{ | ||
return a + b; | ||
} | ||
|
||
double Arithmetic::Subtract(double a, double b) | ||
{ | ||
return a - b; | ||
} | ||
|
||
double Arithmetic::Multiply(double a, double b) | ||
{ | ||
return a * b; | ||
} | ||
|
||
double Arithmetic::Divide(double a, double b) | ||
{ | ||
return a / b; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// MathLibrary.h | ||
#pragma once | ||
|
||
namespace MathLibrary | ||
{ | ||
class Arithmetic | ||
{ | ||
public: | ||
// Returns a + b | ||
static double Add(double a, double b); | ||
|
||
// Returns a - b | ||
static double Subtract(double a, double b); | ||
|
||
// Returns a * b | ||
static double Multiply(double a, double b); | ||
|
||
// Returns a / b | ||
static double Divide(double a, double b); | ||
}; | ||
} |
Oops, something went wrong.