I am following a tutorial to create a wrapper around C++ code, so that it can be called from C#.
I get an error compiling the wrapper though.
Header.h
class MyClass{
public:
MyClass(int x, int y);
double GetSum();
private:
int x_;
int y_;
};
Below is the source file (body.cpp)
#include "Header.h"
MyClass::MyClass(int x, int y)
{
x = 8;
y = 8;
}
double MyClass::GetSum()
{
int r = x_ + y_;
return r;
}
The wrapper class/dll is as below
#include "C:\Users\tumelo\Documents\Visual Studio 2012\Projects\Emgu\MyClassCpp\MyClassCpp\Header.h"
#include "C:\Users\tumelo\Documents\Visual Studio 2012\Projects\Emgu\MyClassCpp\MyClassCpp\Body.cpp"
//for the function you want made avaible from the dll
extern "C" __declspec(dllexport) double GetResults(int x, int y)
{
//create an instance of the class
MyClass myClass(int x, int y);
return myClass.GetSum();
}
I get an in the wrapper class right at the return statement. The class method does not seem to be recognised for some reason. The error reads:
error C2228: left of '.GetSum' must have class/struct/union
What puzzles me is that this is copy and paste from the tutorial but mine does not work. What could I be missing?