matlab mex files and C++ dll (windows)
问题 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