我有一个带类Test的DLL.标题:
class MY_EXPORT Test
{
public:
int doit(const string &str);
};
和来源:
int
Test::doit(const string &str)
{
return int(str.length());
}
现在我从mex文件中使用它:
void
mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
string str("hello!");
Test *t = new Test();
t ->doit(str);
}
问题是,变量str未正确传递给方法doit.在方法里面它包含拉比.我发现通过引用传递的任何对象都会发生这种情况.我做错了什么?请帮忙.
PS:如果我将声明更改为'int doit(const char*)'一切正常.