I have a DLL with class Test. Header:
class MY_EXPORT Test { public: int doit(const string &str); };
and source:
int Test::doit(const string &str) { return int(str.length()); }
Now I use it from mex file:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { string str("hello!"); Test *t = new Test(); t ->doit(str); }
The problem, that variable str
is not passed correctly to the method doit
.
Inside the method it contains rabish. I found that this happens with any object passed by reference. What I am doing wrong? please help.
PS: if I change declaration to 'int doit(const char *)' everything working well.