Hi, I have 2 mex functions compiled from C++. In the first one, it creates Class Object of C++ and the second one does the next work by the same Class Object. I tried(e.g. used persistent, mexMakeMemoryPersistent), but it seems I can not get the Class Object created in the first mex. Did anyone know how to do? PS. It works correctly when I combine the two mex functions, but I must separate them in order to call the second one circularly in my script.
//the first mex void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { if(nrhs!=0) { mexPrintf("do not need argument!\n"); } else { CBodyBasics * classExample=new CBodyBasics; HRESULT hr; hr=classExample->InitializeDefaultSensor(); if (FAILED(hr)) { printf("err in starting!\n"); return; } } }
Best Answer