Date: May 25, 2012 4:38 AM
Author: Pierre
Subject: Re: Making C++ objects persistent between mex calls, and robust.

Well, you actually have two solutions to this problem:
1. Either you go for the pointer-to-integer (or pointer-to-double) and vice versa approach, the integer of which you use as a handle on MATLAB-side
2. or you create a singleton or static storage class which keeps the pointer to your object and from which you can access latter by an explicitly assigned handle (object id or something).

Either way, you would have to get this handle back to MATLAB and keep the handle stored somewhere. For doing so, the wrapper class posted by Oliver is a very good template. I personally ended up with a base class derived from Oliver's class which provides the basic "handle-handling-mechanism" but which can be derived to wrap many different C++ classes very quickly.

Besides that, I'm afraid, I doubt there are other ways for doing this.